|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-03-12 21:00 UTC] sixd@php.net
-Assigned To:
+Assigned To: sixd
[2017-10-24 07:52 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: sixd
+Assigned To:
[2019-01-03 22:13 UTC] camporter1 at gmail dot com
[2021-03-04 12:15 UTC] cmb@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: cmb
[2021-03-04 12:15 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 05:00:01 2025 UTC |
Description: ------------ When using oci_bind_by_name() to add data feed by an associative array, this function adds non-existant data! In the example code the function getDataArray() contains an associative array with a master key called A,B and C. A and B arrays are complete, however for master key C the sub-fields "f1" and "f2" are missing. The code simply loops through the array, binds the values and execute the query. Normally I would expect to run both A and B queries without any problem, however for the C query I would expect that OCI8 lib complains about not all variables bound. See expected/actual result what happened. Reproduce code: --------------- // Requires table: CREATE TABLE TESTOCI(NAME VARCHAR2(10),f1 VARCHAR2(80), f2 VARCHAR2(80)); function getDataArray($which) { $data['A']['name'] = 'NAME_A'; $data['A']['f1'] = 'A_VAL_F1'; $data['A']['f2'] = 'A_VAL_F2'; $data['B']['name'] = 'NAME_B'; $data['B']['f1'] = 'B_VAL_F1'; $data['B']['f2'] = 'B_VAL_F2'; $data['C']['name'] = 'NAME_C'; return($data[$which]); } ini_set('error_reporting', E_ALL|E_NOTICE); $sock = OCILogon('scott','tiger'); $stmt = OCIParse($sock,'INSERT INTO TESTOCI(NAME,F1,F2) VALUES(:name,:f1,:f2)'); $tdat = array('A','B','C'); for($i =0 ; $i < count($tdat); $i++) { $what = array(); printf("HANDLING SET=%s\n",$tdat[$i]); $what = getDataArray($tdat[$i]); print_r($what); foreach($what AS $n => $v) { printf("Calling OCIBindByName(\$stmt,'%s','%s',-1)\n",$n,$what[$n]); $rc = OCIBindByName($stmt,$n,$what[$n],-1); printf("OCIBindByName() returned %s\n",$rc); } print_r($what); OCIExecute($stmt,OCI_DEFAULT); unset($what); } OCIFreeStatement($stmt); OCICOMMIT($sock); OCILogoff($sock); Expected result: ---------------- I would expect that for the data array 'C' an error message should occure stating that not all variables are bound (f1,f2). So the contents of the table should be empty because the code should abort, and COMMIT_ON_SUCCESS is not set. Actual result: -------------- After running the code, the table contents look like this: SQL> SELECT NAME,F1,F2 FROM TESTOCI; NAME F1 F2 -------------------------------- NAME_A A_VAL_F1 A_VAL_F2 NAME_B B_VAL_F1 B_VAL_F2 NAME_C B_VAL_F1 B_VAL_F2 I really wonder how it is possible that the 3rd line contains the values of the previous call??