#32593 [NEW]: odbc with mysql SELECT with placeholders fails
| From: | jake at edge2 dot net | Date: | Tue, 05 Apr 2005 16:09:48 +0000 |
| Subject: | #32593 [NEW]: odbc with mysql SELECT with placeholders fails | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-76399@lists.php.net to get a copy of this message | ||
From: jake at edge2 dot net
Operating system: linux (fc3 and rh9)
PHP version: 4.3.10
PHP Bug Type: ODBC related
Bug description: odbc with mysql SELECT with placeholders fails
Description:
------------
If I use placeholders (?) in a SELECT statement using odbc_prepare() and
odbc_execute(), I get gibberish from the MySQL driver and it works
correctly using the PostgreSQL driver.
If I change the query to "WHERE id=1", it works fine. UPDATES using
placeholders work fine for MySQL.
I am able to do the same queries in C using the same libraries for
unixODBC and MyODBC (and postgres-odbc) and get correct results. This may
not be a PHP and/or PHP-odbc problem, but so far, it looks that way.
I get substantially the same results on an FC3 and a RH9 linux box with
the following versions:
FC3: php-4.3.10-3.2, php-odbc-4.3.10-3.2, unixODBC-2.2.9-1,
MyODBC-2.50.39-19.1, mysql-3.23.58-14
RH9: php-4.2.2-17, php-odbc-4.2.2-17, unixODBC-2.2.3-6,
MyODBC-2.50.39-11, mysql-3.23.54a-11
Reproduce code:
---------------
#!/usr/bin/php
<?php
$conn = odbc_connect('tstdb', 'xxxxx', 'yyyyy');
if ($conn == 0) {
echo("connect failed");
$sqlerr = odbc_errormsg($conn);
echo($sqlerr);
}
$stmt = odbc_prepare($conn, 'SELECT firstname, lastname FROM tst where
id=?');
$result = odbc_execute($stmt, array(1));
if (!$result) {
echo("SELECT failed");
$sqlerr = odbc_errormsg($conn);
echo($sqlerr);
}
while (odbc_fetch_into($stmt, $row)) {
print $row[0] . " " . $row[1] . "\n";
}
?>
Expected result:
----------------
I expect to get the firstname and lastname from the database. The table
is an int id and varchar(20) for the names.
Actual result:
--------------
Some kind of junk: "std n_u"
Postgres gives the correct result (firstname and lastname from the
database)
--
Edit bug report at http://bugs.php.net/?id=32593&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=32593&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=32593&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=32593&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=32593&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=32593&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=32593&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=32593&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=32593&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=32593&r=support
Expected behavior: http://bugs.php.net/fix.php?id=32593&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=32593&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=32593&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=32593&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=32593&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=32593&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=32593&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=32593&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=32593&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=32593&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=32593&r=mysqlcfg