Re: [PHP-DB] Re: ORA-01460 error when useing bind sql on oracle from php
Using OCIBindByName($stmt,$bindname,${bindval$ci},-1); probably gives a warning that call-time pass-by-reference has been deprecated. The OCIBindByName manual entry at http://www.php.net/manual/en/function.ocibindbyname.php has a user comment from alexander dot zimmer at gmx dot at that this doesn't work: foreach ($array as $key = $val) { OCIBindByName($state, $key, $val, -1); } but that this does: foreach ($array as $key = $val) { OCIBindByName($state, $key, $array[$key], -1); } See the entry in the manual page for the explanation. Chris Are Pedersen wrote: Problem solved! As OCIBindByName is binding to the actual variable, that variable must not be changed. I modified my script to look like this: ---***--- $ci=0; foreach ($bindargs as $bindname = $bindvalue){ ${bindval$ci}=$bindvalue; OCIBindByName($stmt,$bindname,${bindval$ci},-1); $ci++; } ---***--- Are Pedersen wrote: I get ORA-01460: unimplemented or unreasonable conversion requested when useing bind-sql on Oracle 9i. I am useing OCI 8.1 client in PHP. What is wrong? And what does this message mean? Here is the code: ---***--- $bindarray1=array(':project1'=$project); $bindarray1[':userid']=$userid; $rs = sql_query($qs,$bindarray1); function sql_query($qs,$bindargs) { $stmt = @OCIParse($this-db_sqlhandler, $qs); if (!$stmt) { return false; } //bind all the variables if (is_array($bindargs)){ foreach ($bindargs as $bindname = $bindvalue){ OCIBindByName($stmt,$bindname,$bindvalue,-1); } } if (@OCIExecute($stmt)) { return $stmt; } $DB_ERROR = OCIError($stmt); return $DB_ERROR; } ---***--- -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: ORA-01460 error when useing bind sql on oracle from php
Sorry about replying to my own posts, but... Problem solved! As OCIBindByName is binding to the actual variable, that variable must not be changed. I modified my script to look like this: ---***--- $ci=0; foreach ($bindargs as $bindname = $bindvalue){ ${bindval$ci}=$bindvalue; OCIBindByName($stmt,$bindname,${bindval$ci},-1); $ci++; } ---***--- Are Pedersen wrote: I get ORA-01460: unimplemented or unreasonable conversion requested when useing bind-sql on Oracle 9i. I am useing OCI 8.1 client in PHP. What is wrong? And what does this message mean? Here is the code: ---***--- $bindarray1=array(':project1'=$project); $bindarray1[':userid']=$userid; $rs = sql_query($qs,$bindarray1); function sql_query($qs,$bindargs) { $stmt = @OCIParse($this-db_sqlhandler, $qs); if (!$stmt) { return false; } //bind all the variables if (is_array($bindargs)){ foreach ($bindargs as $bindname = $bindvalue){ OCIBindByName($stmt,$bindname,$bindvalue,-1); } } if (@OCIExecute($stmt)) { return $stmt; } $DB_ERROR = OCIError($stmt); return $DB_ERROR; } ---***--- vardump of bindargs: array(2) { [:project1]= int(1) [:userid]= string(5) 10001 } vardump of DB_ERROR: array(4) { [code]= int(1460) [message]= string(62) ORA-01460: unimplemented or unreasonable conversion requested [offset]= int(0) [sqltext]= string(365) SELECT acl.prjid, acl.groupid, acl.read_access , acl.write_access,acl.delete_access,acl.change_access FROM StructureTreeTbl outree, GroupChildrenTbl gg2, MembersTbl memb2, ACL acl WHERE (memb2.personid=:userid AND memb2.groupid=gg2.gchildid AND gg2.groupid=outree.orgchild AND outree.orgid = acl.groupid AND acl.prjid=:project1) } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php