ID: 48324
Updated by: [email protected]
Reported By: roger dot robins at det dot nsw dot edu dot au
-Status: Open
+Status: Bogus
Bug Type: OCI8 related
Operating System: Linux Redhat ES 3.0
PHP Version: 5.2.9
New Comment:
Passing a -1 length to the oci_bind_by_name call allocates only enough
storage for the current size of $id at the time of the call. A size of 1
is used for a null.
Instead of -1, pass a length big enough to hold your largest expected
return value.
Previous Comments:
------------------------------------------------------------------------
[2009-05-19 01:48:11] roger dot robins at det dot nsw dot edu dot au
Description:
------------
When INSERTing a record into a table that has a database sequence for
calculating the table id (unique identifier) and that sequence's
next_val has reached double figures; and you use oci_bind_by_name to
return the id of the inserted row; then only the first digit of the two
digit row id is returned.
Code:
$sql = "INSERT INTO {$this->prefix}$table ($fields) VALUES($values)
$returning";
$id = null;
$this->query_start($sql, $params, SQL_QUERY_INSERT);
$stmt = $this->parse_query($sql);
$descriptors = $this->bind_params($stmt, $params, $table);
if ($returning) {
oci_bind_by_name($stmt, ":oracle_id", $id, -1, SQLT_LNG);
}
$result = oci_execute($stmt);
$this->free_descriptors($descriptors);
$this->query_end($result, $stmt);
oci_free_statement($stmt);
Reproduce code:
---------------
Environment:
PHP 5.2.9 compiled again Oracle 10.2 or 11.1 client, connecting to
Oracle 10.2 database.
'./configure' '--with-apxs2=/usr/local/apache/bin/apxs'
'--with-mysql=/usr/bin' '--enable-soap' '--with-curl' '--with-xmlrpc'
'--enable-mbstring' '--with-openssl' '--enable-zip' '--with-ldap'
'--with-oci8=/apps/oraoid/app/oraoid/product/11.1.0/client_1'
Expected result:
----------------
When the database table sequence reaches double figures, the correct
table (seed) id should be returned as a result of sql INSERT command and
calling oci_bind_by_name.
Actual result:
--------------
The id returned is only the first digit of the real row id.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48324&edit=1