我有这一法典:
$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);
}
}
第一个问题已经执行,但第二个没有执行。 没有产生我的错误。 任何想法?