php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37286 Documented prepare use fails
Submitted: 2006-05-02 21:42 UTC Modified: 2006-05-03 06:57 UTC
From: vldi at yahoo dot com Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5CVS-2006-05-02 (snap) OS: Suse 10
Private report: No CVE-ID: None
 [2006-05-02 21:42 UTC] 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 />

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-02 21:48 UTC] tony2001@php.net
There is absolutely no need to report the same problem twice.
 [2006-05-02 22:04 UTC] vldi at yahoo dot com
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.
 [2006-05-03 06:57 UTC] tony2001@php.net
No, this is the very same problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 12 09:01:27 2024 UTC