php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #32395 odbc_execute modifies the param array
Submitted: 2005-03-21 18:38 UTC Modified: 2006-01-03 18:36 UTC
Votes:4
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:4 (100.0%)
Same OS:4 (100.0%)
From: treehousetim at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5CVS, 4CVS (2005-03-24) OS: *
Private report: No CVE-ID: None
 [2005-03-21 18:38 UTC] treehousetim at gmail dot com
Description:
------------
Calling odbc_execute modifies the input paramList array.
This happens even when I try to make a copy of the array before passing it to odbc_execute.

Specifically, null parameters are changed to zero length strings.


Reproduce code:
---------------
<?php
    function x( $query, $paramList )
    {
        $result = odbc_execute( $query, $paramList );
	    $paramList['timg'] = "Tim Gallagher";
    }

    // change the server and database below to the correct values for your setup
    $connection = 'DRIVER={SQL Server};SERVER=server;DATABASE=database';

    $handle = odbc_connect( $connection, '', '' );
    $query  = odbc_prepare( $handle, "INSERT INTO TEST (ID,CHECK_LONG,CHECK_VARCHAR) VALUES (?, ?, ? )" );

    $paramList[0] = 44;
    $paramList[1] = null;
    $paramList[2] = null;

    echo gettype($paramList[2]) . "\n"; // echos NULL
    x( $query, $paramList );
    echo gettype($paramList[2]) . "\n"; // echos string
    
    print_r( $paramList )

?>

Expected result:
----------------
NULL
string
Array
(
    [0] => 44
    [1] => 
    [2] => 
)

Actual result:
--------------
NULL
NULL
Array
(
    [0] => 44
    [1] => 
    [2] => 
)

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-21 22:45 UTC] sniper@php.net
Please change print_r -> var_dump to get more detailed information out of the $paramList variable.
 [2005-03-21 23:04 UTC] treehousetim at gmail dot com
More specifically, all entries in the array are changed to string types.
here is more data as requested using var_dump instead of print_r.

BEFORE:

array(3) {
  [0]=>
  int(44)
  [1]=>
  NULL
  [2]=>
  NULL
}

AFTER:
array(3) {
  [0]=>
  string(2) "44"
  [1]=>
  string(0) ""
  [2]=>
  string(0) ""
}
 [2005-12-25 17:41 UTC] sniper@php.net
It has to change the input array, because it
should convert all the values in strings without separating them to be able to get returned values from stored proc.

Needs documenting.
 [2006-01-03 18:36 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"Elements of this array will be converted to strings by calling this function."
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Aug 19 10:01:29 2024 UTC