Bug #80152 [PATCH]: odbc_execute() moves internal pointer of supplied $params
Edit report at https://bugs.php.net/bug.php?id=80152&edit=1
ID: 80152
Patch added by: cmb@php.net
Reported by: cmb@php.net
Summary: odbc_execute() moves internal pointer of supplied
$params
Status: Assigned
Type: Bug
Package: ODBC related
Operating System: *
PHP Version: 7.3.22
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: Fix #80152: odbc_execute() moves internal pointer of $params
On GitHub: https://github.com/php/php-src/pull/6219
Patch: https://github.com/php/php-src/pull/6219.patch
Previous Comments:
------------------------------------------------------------------------
[2020-09-26 11:08:32] cmb@php.net
Description:
------------
When odbc_execute() is applied to a statement with N placeholders
(where N > 0), the internal array pointer of the supplied $params
array is moved to the Nth position. Since $params is passed
by-val, it must not be modified, not even its internal pointer.
Test script:
---------------
<?php
$conn = odbc_connect($dsn, $user, $pass);
odbc_exec($conn,"CREATE TABLE test (id INT, name CHAR(24))");
$stmt = odbc_prepare($conn,"INSERT INTO test (id, name) VALUES (?, ?)");
$params = [1, "John", "Lim"];
var_dump(key($params));
odbc_execute($stmt, $params);
var_dump(key($params));
?>
Expected result:
----------------
int(0)
int(0)
Actual result:
--------------
int(0)
int(2)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80152&edit=1
Thread (3 messages)