I have this code:
$this->db->beginTransaction();
$query = 'INSERT INTO `table1` VALUES (NULL,:a,:b,NULL,NOW())';
$sth = $this->db->prepare($query);
foreach ($values as $k => $v) {
$sth->bindParam(':' . $k, $v, PDO::PARAM_INT);
}
$this->executeQueryRollbackOnException($sth, 'Message_1');
$resetId = $this->db->lastInsertId();
$query = 'UPDATE `table2` SET c=:c,d=:d WHERE reset_id IS NULL';
$sth = $this->db->prepare($query);
foreach ($values2 as $k => $v) {
$sth->bindParam(':' . $k, $v, PDO::PARAM_INT);
}
$this->executeQueryRollbackOnException($sth, 'Message_2');
Zend_Debug::dump($sth->rowCount(), 'Affected'); // This is 0
// Commit
$this->db->commit();
...
private function executeQueryRollbackOnException($sth, $message) {
try {
$sth->execute();
} catch (Exception $e) {
$this->logSQLError($e);
$this->db->rollBack();
throw new Exception($message);
}
}
First query is executed but the second is not. No mysql error produced. Any ideas ?