Bug #67557 [Opn->Nab]: PHP PDO insert using transaction doesn't show error
| From: | mbeccati@php.net | Date: | Fri, 31 Oct 2014 18:26:34 +0000 |
| Subject: | Bug #67557 [Opn->Nab]: PHP PDO insert using transaction doesn't show error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188390@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67557&edit=1
ID: 67557
Updated by: mbeccati@php.net
Reported by: marcio at evomaster dot com dot br
Summary: PHP PDO insert using transaction doesn't show error
-Status: Open
+Status: Not a bug
Type: Bug
Package: PDO PgSQL
Operating System: CentOS 6.5
PHP Version: 5.5.14
-Assigned To:
+Assigned To: mbeccati
Block user comment: N
Private report: N
New Comment:
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'
Previous Comments:
------------------------------------------------------------------------
[2014-07-03 12:46:00] 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-07-03 03:13:07] 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
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67557&edit=1