Home >Backend Development >PHP Tutorial >PHP pdo transaction rollback code example_PHP tutorial

PHP pdo transaction rollback code example_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:04:271458browse

PHP pdo transaction rollback code example
$this->beginTransaction();
$this->exec('update people set age=2');

//$step1 = mysql tutorial_error();//In your class, change it to if there is an error in executing sql, get the error code, and the corresponding function

$this->exec('INSERT INTO course (course,num) VALUES ("Mathematics",100)');

//$step2 = mysql_error();


if (!$step1 && !$step2)
{
$this->commit();
}
else
{
$this->rollBack();
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630862.htmlTechArticlePHP pdo transaction rollback code example $this-beginTransaction(); $this-exec('update people set age =2'); //$step1 = mysql tutorial_error();//In your class, change it to if there is an error in executing sql, get...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn