Home > Backend Development > PHP Tutorial > 请教pdo的事务处理中可以使用预处理么

请教pdo的事务处理中可以使用预处理么

WBOY
Release: 2016-06-13 13:07:41
Original
1082 people have browsed it

请问pdo的事务处理中可以使用预处理么?
请问pdo的事务处理中可以使用预处理么?例如下面的代码异常后,可以回滚事务么?

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
try{
    $pdo->beginTransaction();
    $sql = 'INSERT ...';
    $pdo_pre = $pdo->prepare($sql);
    $pdo_pre->execute();
}catch(PDOException $e){
    $pdo->->rollBack();
}

Copy after login

PDO的事务操作仅对PDO方法生效,还是PDO和PDOStatement都生效呢?
谢谢!

------解决方案--------------------
都生效的
但是我在你的代码里面没有看到commit
------解决方案--------------------
看下mysql的事务
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template