#37286 [NEW]: Documented prepare use fails
| From: | vldi at yahoo dot com | Date: | Tue, 02 May 2006 21:42:53 +0000 |
| Subject: | #37286 [NEW]: Documented prepare use fails | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-96501@lists.php.net to get a copy of this message | ||
From: vldi at yahoo dot com
Operating system: Suse 10
PHP version: 5CVS-2006-05-02 (snap)
PHP Bug Type: PDO related
Bug description: Documented prepare use fails
Description:
------------
An example used at the page http://www.php.net/manual/en/ref.pdo.php at
the section "Example 9. Calling a stored procedure with an output
parameter" quietly fails at prepare statement. connection established
correctly because the procedure gets properly created. My configure is:
'./configure' '--prefix=/usr/local/php5' '--with-openssl'
'--with-kerberos' '--with-zlib' '--with-bz2'
'--enable-calendar'
'--with-curl' '--with-curlwrappers' '--enable-exif'
'--enable-ftp'
'--with-gettext' '--with-ldap' '--with-ldap-sasl'
'--with-mssql=/usr/local/freetds' '--with-mysql' '--with-mysql-sock'
'--with-mysqli' '--with-unixODBC=/usr' '--with-pdo-mysql'
'--with-pdo-odbc=unixODBC,/usr' '--enable-sockets' '--enable-sysvmsg'
'--enable-sysvsem' '--enable-sysvshm' '--with-xsl'
'--with-pear'
'--disable-cgi' '--with-apxs2=/usr/local/apache2/bin/apxs'
'--with-config-file-path=/etc/php.ini' '--enable-debug'
Reproduce code:
---------------
<html><body><?php
$dbuser='user1';
$dbpassword='';
$dsn = "DRIVER=FreeTDS;SERVERNAME=server1;DATABASE=testdb;UID=$dbuser;";
try {
$dbh = new PDO('odbc:'.$dsn, $dbuser, $dbpassword );
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->exec("
create procedure dbo.pdotest @param_out varchar(10) = '' output
as set @param_out = 'the_string'
");
$stmt = $dbh->prepare("CALL dbo.pdotest(?)");
print "<p>"; var_dump( $stmt ); print "</p>";
$stmt->bindParam(1, $return_value, PDO::PARAM_STR, 4000);
$stmt->execute();
print "<p>procedure returned $return_value</p>\n";
} catch ( PDOException $e ) {
print "<p>Failed:
".$e->getMessage()."</p></body></html>";
die();
}
?></body></html>
Expected result:
----------------
either returned value of failure message, but graceful script completion.
Actual result:
--------------
script aborting with html
<html><body><p>bool(false)
</p><br />
<b>Fatal error</b>: Call to a member function bindParam() on a non-object
in <b>/srv/www/htdocs/ChangeMgmt/pdotest.php</b> on line <b>14</b><br
/>
--
Edit bug report at http://bugs.php.net/?id=37286&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37286&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=37286&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37286&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37286&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=37286&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37286&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37286&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37286&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37286&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37286&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=37286&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=37286&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37286&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37286&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37286&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37286&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37286&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37286&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37286&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37286&r=mysqlcfg