Answer the question
In order to leave comments, you need to log in
How do transactions work in Wordpress?
Good afternoon everyone, how to work with transactions in Wordpress, I use the following code, attention - the commit is commented out:
try {
$wpdb->query('START TRANSACTION');
$result = $wpdb->query('TRUNCATE TABLE wp_competition_history');
if (!$result) {
throw new Exception("Ошибка БД");
}
//$wpdb->query('COMMIT');
} catch (Exception $ex) {
$wpdb->query('ROLLBACK');
}
Answer the question
In order to leave comments, you need to log in
It's not clear whether you defined global $wpdb somewhere earlier;
Try replacing the condition with this
if (false === $result) {
throw new Exception("Ошибка БД. ".$wpdb->last_error);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question