problem with ibase_execute called through call_user_func_array()
| Bug #11924 | problem with ibase_execute called through call_user_func_array() | ||||
|---|---|---|---|---|---|
| Submitted: | 2001-07-06 06:03 UTC | Modified: | 2003-07-09 19:17 UTC | ||
| From: | flying at dom dot natm dot ru | Assigned: | |||
| Status: | Closed | Package: | InterBase related | ||
| PHP Version: | 4.3.0-dev | OS: | Windows 2000 | ||
| Private report: | No | CVE-ID: | None | ||
[2001-07-06 06:03 UTC] flying at dom dot natm dot ru
It seems to be a problem when ibase_execute called indirectly, through call_user_func_array().
Look at the following piece of code:
$args = array('some text','amother text');
$query = ibase_prepare($conn,"insert into MY_TABLE (INT_FIELD, STR_FIELD) values (?,?)");
array_unshift($args,$query);
print_r($args);
$rs = call_user_func_array('ibase_execute',$args);
print_r($args);
ibase_free_query($query);
MY_TABLE table contains two columns:
INT_FIELD INTEGER,
STR_FIELD VARCHAR(50)
Imagine, that we're make an error, and pass string values for both fields.
No error will be given, but at second print_r() first item inro $args array
will be equal to 0 instead of 'some text'.
As I can understand, all query parameters are replaced by values, actually
stored into database (like they are passed by reference,
but allow_call_time_pass_reference options is turned off).
If it is not a bug, but a "feature", it must be documented, to avoid future misunderstandings.
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2002-05-25 09:21 UTC] derick@php.net
[2002-05-25 09:27 UTC] flying at dom dot natm dot ru
[2002-05-25 09:41 UTC] derick@php.net
[2002-05-25 09:54 UTC] flying at dom dot natm dot ru
[2002-05-26 04:35 UTC] derick@php.net
[2002-05-26 04:51 UTC] flying at dom dot natm dot ru
Here is full information, test database creation script included: test.sql ======== SET SQL DIALECT 3; SET NAMES NONE; CREATE DATABASE 'C:\TEST.GDB' USER 'SYSDBA' PASSWORD 'masterkey' PAGE_SIZE 4096 DEFAULT CHARACTER SET NONE; CREATE GENERATOR GEN_MY_TABLE_ID; CREATE TABLE MY_TABLE ( ID INTEGER NOT NULL, STR_FIELD VARCHAR(50), INT_FIELD INTEGER); ALTER TABLE MY_TABLE ADD CONSTRAINT PK__MY_TABLE PRIMARY KEY (ID); SET TERM ^ ; CREATE TRIGGER MY_TABLE_BI FOR MY_TABLE ACTIVE BEFORE INSERT POSITION 0 AS BEGIN IF (NEW.ID IS NULL) THEN NEW.ID = GEN_ID(GEN_MY_TABLE_ID,1); END ^ SET TERM ; ^ test.php ======== <?php ibase_connect('localhost:c:\test.gdb','SYSDBA','masterkey'); $args = array('some text','another text'); $query = ibase_prepare('insert into MY_TABLE (INT_FIELD, STR_FIELD) values (?,?)'); array_unshift($args,$query); print_r($args); $rs = call_user_func_array('ibase_execute',$args); print_r($args); ibase_free_query($query); ibase_close(); ?> Expected results: ================= Array ( [0] => Resource id #2 [1] => some text [2] => another text ) Array ( [0] => Resource id #2 [1] => some text [2] => another text ) Actual results: =============== Array ( [0] => Resource id #2 [1] => some text [2] => another text ) Array ( [0] => Resource id #2 [1] => 0 [2] => another text ) --------------------------------------- As you can see - after calling call_user_func_array() data into $args[1] has been changed, while it should stay the same.[2002-06-27 01:00 UTC] php-bugs at lists dot php dot net
[2002-06-27 03:40 UTC] flying at dom dot natm dot ru
[2002-06-28 06:28 UTC] flying at dom dot natm dot ru
[2003-05-07 04:45 UTC] flying at dom dot natm dot ru