php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67557 PHP PDO insert using transaction doesn't show error
Submitted: 2014-07-03 03:13 UTC Modified: 2014-10-31 18:26 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: marcio at evomaster dot com dot br Assigned: mbeccati (profile)
Status: Not a bug Package: PDO PgSQL
PHP Version: 5.5.14 OS: CentOS 6.5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: marcio at evomaster dot com dot br
New email:
PHP Version: OS:

 

 [2014-07-03 03:13 UTC] marcio at evomaster dot com dot br
Description:
------------
---
From manual page: http://www.php.net/pdostatement.execute
---

$Pdo = new PDO('pgsql:host=localhost;port=5432;dbname=mydb', 'user', 'password');

$options = = array(
    PDO::ATTR_ERRMODE          => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_CURSOR           => PDO::CURSOR_FWDONLY,
    PDO::ATTR_EMULATE_PREPARES => false
);

$sql = 'INSERT INTO my_table (
            field_a,
            field_b
        ) VALUES (
            :field_a,
            :field_b
        )';

$Pdo->beginTransaction();

$Ps = $Pdo->prepare($sql, $options);

$Ps->execute(array(
    ':field_a' => 'Field A',
    ':field_b' => 'Field B',
    ':field_c' => 'Field C'
));

$Pdo->commit();

Test script:
---------------
$Ps-execute() returns false, but doesn't show an error message telling that there are more columns than in the SQL specified.

In my real case i have more than one SQL statement, because of this i am using a transaction.

Expected result:
----------------
I expect that PHP throw an exception or error

Actual result:
--------------
PHP didn't trigger exception or error and proceed with the code

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-03 12:46 UTC] marcio at evomaster dot com dot br
I forgot to say that is very critical the fact of $Pdo->commit() returns true, even with the $Ps->execute() failure.
 [2014-10-31 18:26 UTC] mbeccati@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: mbeccati
 [2014-10-31 18:26 UTC] mbeccati@php.net
Thanks for the bug report. I'm afraid I can't reproduce the bug.

I get:

Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: :field_c'
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC