php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70313 PDO statement fails to throw exception.
Submitted: 2015-08-20 15:17 UTC Modified: 2016-07-10 10:55 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: spectral2k at hotmail dot com Assigned: mbeccati (profile)
Status: Closed Package: PDO PgSQL
PHP Version: 5.5.28 OS: Ubuntu
Private report: No CVE-ID: None
 [2015-08-20 15:17 UTC] spectral2k at hotmail dot com
Description:
------------
PDO fails to return SQL errors from PostgreSQL when using an invalid SQL statement and integer based bindParam calls.

If you remove the bindParam calls the execute call will throw an exception.

Test script:
---------------
<?php

$dbh = new PDO('###', '###', '###');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare(");");

$a = 'a';
$b = 'b';

$stmt->bindParam(1,$a);
$stmt->bindParam(2,$b);
$stmt->execute();

Expected result:
----------------
An exception should always be thrown when invalid SQL is executed.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-20 16:13 UTC] nsadjadi at gmail dot com
I tested it on MySQL and it gives exception as expected so must probably this is not bug of pdo but bug of PostgreSQL.
 [2016-07-10 10:55 UTC] mbeccati@php.net
-Package: PDO related +Package: PDO PgSQL -Assigned To: +Assigned To: mbeccati
 [2016-07-10 12:40 UTC] mbeccati@php.net
Automatic comment on behalf of mbeccati
Revision: http://git.php.net/?p=php-src.git;a=commit;h=219ebcb68984a0af524336b165a849781ee65758
Log: Fixed bug #70313 PDO statement fails to throw exception
 [2016-07-10 12:40 UTC] mbeccati@php.net
-Status: Assigned +Status: Closed
 [2016-10-17 10:11 UTC] bwoebi@php.net
Automatic comment on behalf of mbeccati
Revision: http://git.php.net/?p=php-src.git;a=commit;h=219ebcb68984a0af524336b165a849781ee65758
Log: Fixed bug #70313 PDO statement fails to throw exception
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 11:01:30 2024 UTC