Answer the question
In order to leave comments, you need to log in
How to catch errors when writing and updating to the database from a function?
I have two functions that perform the usual insert and update records in the database
user_insert($args); //эта функция добавляет запись в бд
user_update($args); //эта обновляет запись в базе
$pdo->beginTransaction();
try {
user_insert($args);
user_update($args);
} catch (\PDOException $e) {
$pdo->rollback();
throw $e;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question