ITKeyword,专注技术干货聚合推荐

注册 | 登录

IOS Objective C Draw Bitmap on View

itPublisher 分享于

2021腾讯云限时秒杀,爆款1核2G云服务器298元/3年!(领取2860元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1062

2021阿里云最低价产品入口+领取代金券(老用户3折起),
入口地址https://www.aliyun.com/minisite/goods

up vote 1 down vote favorite I have a SQL transaction similar to the one below. I am unable to obtain the result of the 3rd query in the transaction using PHP function PDO::fetch() $database = DatabaseFactory::getFactory()->getConnection();

$sql = "BEGIN;

DELETE FROM users WHERE ID = 4;

UPDATE audit SET nousers= nousers - 1 WHERE ID = 4;

SELECT nousers FROM audit WHERE ID = 4;

COMMIT;";

$query = $database->prepare($sql);

$query->execute();

How do I use $query->fetch() to obtain the result of the 3rd query in the transaction? php mysql pdo transactions
  |
  this question edited Apr 11 '15 at 5:32 Odedra 6,283 7 16 42 asked Apr 4 '15 at 14:38 wolf3D 20 7      Please check the link:- stackoverflow.com/questions/2708237/… –  Alive to Die Apr 4 '15 at 14:47      @anantkumarsingh the link does not give an answer regarding obtaining the result of a transaction query using PDO::fetch(). I am not currently using mysql_* functions cause they are deprecated. Thanks for the help. –  wolf3D Apr 4 '15 at 15:10



 |  1 Answers

up vote 0 down vote You have five queries in your transaction, counting BEGIN and COMMIT. Call prepare() and execute() five times, one for each of the queries. For your SELECT query, retrieve and examine the result set. There's no need to put all queries of a transaction into a single prepare / execute cycle. The whole point of the transaction is to allow you to run multiple queries so they look like one unitary operation to other clients of the database server.
  |
  this answer answered Apr 4 '15 at 15:44 O. Jones 44.8k 9 55 93



 | 

up vote 1 down vote favorite I have a SQL transaction similar to the one below. I am unable to obtain the result of the 3rd query in the transaction using PHP function PDO::fetch()

相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。