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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:57:21
Original
1022 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
Latest Issues
Database pdo connection problem
From 1970-01-01 08:00:00
0
0
0
pdo installation
From 1970-01-01 08:00:00
0
0
0
$pdo->exec($sql);Why does it always return false?
From 1970-01-01 08:00:00
0
0
0
PHP PDO predefined constants
From 1970-01-01 08:00:00
0
0
0
PDO query data error
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template