note 105911 added to function.oci-bind-by-name

From: Date: Sun, 25 Sep 2011 03:03:43 +0000
Subject: note 105911 added to function.oci-bind-by-name
Groups: php.notes 
Request: Send a blank email to php-notes+get-183412@lists.php.net to get a copy of this message
I unfortunately spent the whole day trying to make this work as part of OCI bind_by_name insert: if(is_numeric($v2)){ oci_bind_by_name($stmth, $bvar, $v2, -1, OCI_B_INT); }else{ $v2 = (string) $v2; oci_bind_by_name($stmth, $bvar, $v2, -1, SQLT_CHR); } The string field is always inserting correctly w/o any truncation. The string field is a varchar2(160) CHAR, but the data used to populate it is 40 chars in length. The numeric part is of Type Number in the database which is being used to store unix time (10 digit seconds since 1970/01/01. The problem, the insert was truncating to 9 digits with some bogus value not even related to the input i.e., it's not just a matter of dropping the leftmost or rightmost digit, it'll just insert a 9 digit bogus number. The only way I was able to resolve this for the numeric field was to set the maxlength to 8 (not 10 which is the number of digits in the input): if(is_numeric($v2)){ oci_bind_by_name($stmth, $bvar, $v2, 8, OCI_B_INT); }else{ $v2 = (string) $v2; oci_bind_by_name($stmth, $bvar, $v2, -1, SQLT_CHR); } Hopefully you'll see this soon before you expend a lot of time repeating the same problem I had. ---- Server IP: 69.147.83.197 Probable Submitter: 98.64.170.27 ---- Manual Page -- http://www.php.net/manual/en/function.oci-bind-by-name.php Edit -- https://master.php.net/note/edit/105911 Del: integrated -- https://master.php.net/note/delete/105911/integrated Del: useless -- https://master.php.net/note/delete/105911/useless Del: bad code -- https://master.php.net/note/delete/105911/bad+code Del: spam -- https://master.php.net/note/delete/105911/spam Del: non-english -- https://master.php.net/note/delete/105911/non-english Del: in docs -- https://master.php.net/note/delete/105911/in+docs Del: other reasons-- https://master.php.net/note/delete/105911 Reject -- https://master.php.net/note/reject/105911 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#183412) next »