I created a database wrapper with extra functionality around the PDO system (yes, I know a wrapper around the shell, but it's just a PDO with some additional features). But I noticed a problem.
The following does not work as it should:
<?php
var_dump($db->beginTransaction());
$db->query('
INSERT INTO test
(data) VALUES (?)
;',
array(
'Foo'
)
);
print_r($db->query('
SELECT *
FROM test
;'
)->fetchAll());
var_dump($db->rollBack());
print_r($db->query('
SELECT *
FROM test
;'
)->fetchAll());
?>
var_dump shows that the beginTransaction and rollBack functions return true, so there are no errors.
I expected the first call to print_r to display an array of N elements, and the second to N-1. But this is not so, both of them show the same number of elements.
My query $ db-> (<sql>, <values>) does not call anything other than $ pdo-> prepare (<sql>) β execute (<values>) (with additional error handling in the course).
, , MySQL , PDO implenmentaties - .
- , ?