#37286 [Bgs->Opn]: Documented prepare use fails
| From: | vldi at yahoo dot com | Date: | Tue, 02 May 2006 22:04:42 +0000 |
| Subject: | #37286 [Bgs->Opn]: Documented prepare use fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-96503@lists.php.net to get a copy of this message | ||
ID: 37286
User updated by: vldi at yahoo dot com
Reported By: vldi at yahoo dot com
-Status: Bogus
+Status: Open
Bug Type: PDO related
Operating System: Suse 10
PHP Version: 5CVS-2006-05-02 (snap)
New Comment:
I am sure that is NOT the same problem. Im the bug 37285 which you
probably refer to the problem is with the error handling on a bad input
(the wrong sql). Here the problem is about the prerape statement failing
on the perceivably correct SQL, taken from the PDO documentation.
Please, reconsider. I apologise if I am mistaken, anyhow.
Previous Comments:
------------------------------------------------------------------------
[2006-05-02 21:48:49] tony2001@php.net
There is absolutely no need to report the same problem twice.
------------------------------------------------------------------------
[2006-05-02 21:42:53] vldi at yahoo dot com
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 this bug report at http://bugs.php.net/?id=37286&edit=1