From: vldi at yahoo dot com
Operating system: Suse 10
PHP version: 5CVS-2006-05-02 (snap)
PHP Bug Type: PDO related
Bug description: PDOConnection->exec fails silently
Description:
------------
PDO does not raise the exception when SQL fails.
Config 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
$dsn = 'DRIVER=FreeTDS;SERVERNAME=server1;DATABASE=testdb;UID=user1;';
$dbuser='foolproof';
$dbpassword='';
$dbh = null;
try {
$dbh = new PDO('odbc:'.$dsn, $dbuser, $dbpassword );
if ( ! $dbh ) {
print "<p>No DBH</p></body></html>";
die();
};
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->exec("
create procedure pdotest
@param_in int = null,
@param_out int output
as
set @param_out = @param_in
go
");
} catch ( PDOException $e ) {
print "<p>Failed: ".$e->getMessage()."</p></body></html>";
die();
}
?>
<p>Succedeed</p>
</body></html>
Expected result:
----------------
Expect to either see the new procedure created, or exception raised.
Actual result:
--------------
The page displays "Succeesed", yet no procedure created in the database.
--
Edit bug report at http://bugs.php.net/?id=37285&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=37285&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=37285&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=37285&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=37285&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=37285&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=37285&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=37285&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=37285&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=37285&r=support
Expected behavior: http://bugs.php.net/fix.php?id=37285&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=37285&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=37285&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=37285&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=37285&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=37285&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=37285&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=37285&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=37285&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=37285&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=37285&r=mysqlcfg