Bug #37285 [Com]: PDOConnection->exec fails silently

From: Date: Tue, 25 Mar 2014 14:54:11 +0000
Subject: Bug #37285 [Com]: PDOConnection->exec fails silently
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184883@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=37285&edit=1 ID: 37285 Comment by: contact at nicolasbouliane dot com Reported by: vldi at yahoo dot com Summary: PDOConnection->exec fails silently Status: No Feedback Type: Bug Package: PDO related Operating System: Suse 10 PHP Version: 5CVS-2006-05-02 (snap) Assigned To: wez Block user comment: N Private report: N New Comment: I have the same bug in 5.3.19 on CentOS when I use dbLib to connect to SQL Server 2008. I get warnings, but blatantly invalid queries don't raise exception, despite setting ATTR_ERRMODE. The attribute is set, but it has no effect. Previous Comments: ------------------------------------------------------------------------ [2009-05-03 01:00:00] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2009-04-25 14:38:21] jani@php.net Please try using this CVS snapshot: http://snaps.php.net/php5.2-latest.tar.gz For Windows: http://windows.php.net/snapshots/ ------------------------------------------------------------------------ [2007-07-11 15:48:18] pickscrape at gmail dot com I am able to reproduce this using the following example: <?php $objDB = new PDO('mysql:dbname=mysql;host=127.0.0.1', 'root', ''); $objDB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $objStmt = $objDB->prepare('I do not even remotely resemble a query.'); $objStmt->execute(); ?> The key in my case is in changing the connection parameters. If I'm connecting to a MySQL 5 server, the exception is thrown correctly. If I'm connecting to a MySQL 4.0 server, no exception is thrown. At the client end I have MySQL 5 libraries installed, running bundled PDO via PHP 5.2.2. ------------------------------------------------------------------------ [2006-06-02 18:23:30] moy at ivsol dot net Im having the same issue. PHP version: PHP 5.1.4-pl0-gentoo with Hardening-Patch 0.4.9 (cli) (built: May 16 2006 16:51:09) I dont think It matters having Hardening Patch. I have used the following code to test: <?php /*bug: 37285*/ try { $pdo = new PDO('pgsql:dbname=iss-callmanager;user=postgres;password=voip123admin;host=localhost'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /* the following statement have SQL error, no space between SET value and WHERE clause */ $statement = $pdo->prepare('UPDATE patterns SET pattern_name = :pattern_nameWHERE pattern_id = :pattern_id'); $pattern_name = 'SIP Internas'; $pattern_id = 4; $values = array(':pattern_name' => $pattern_name, ':pattern_id' => $pattern_id); $result = $statement->execute($values); var_dump($result); var_dump($statement->errorInfo()); } catch ( PDOException $error ) { echo $error->getMessage() . "\n"; } ?> I was expecting an exception, or the query executed successfully, nothing happens. I have noticed that postgresql executes the query correctly If I put the literal query in the command line, no matter that no space exists between the SET value and the starting of the WHERE clause. ------------------------------------------------------------------------ [2006-05-04 15:57:02] smlerman at gmail dot com Well, I found the problem with my code. $stmt->bindValue(':something', $some_array, PDO::PARAM_INT); Obviously, trying to bind an array as an integer doesn't work too well. Some type of error message/exception would be nice to see though. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=37285 -- Edit this bug report at https://bugs.php.net/bug.php?id=37285&edit=1

« previous php.bugs (#184883) next »