我需要知道在提交更改之前在事务中更改了哪些值。是否可以获得原始值(不是未提交的值?)。例如(虚构代码):
try {
$pdo->beginTransaction();
$pdo->exec('UPDATE items SET name = :name, text = :text WHERE id = :id', $newData);
//If the update was fine:
$oldData = $pdo->query('SELECT * FROM items WHERE id = :id LIMIT 1', array(':id' => $newData['id']);
$diff = array_diff_assoc($newData, $oldData);
echo 'Item was update successfully with new values in '.implode(', ', array_keys($diff));
$pdo->commit();
} catch (Exception $E) {
echo 'something is wrown';
$pdo->rollBack();
}
在事务中选择数据时,此数据是更改后的数据,而不是原始数据。mysql中有什么选项可以跳过这个吗?