【发布时间】:2012-05-17 00:45:15
【问题描述】:
函数调用可以发生在 PDO 事务块中吗?这是简化代码(使用 MySql 数据库)...
try{
$db->beginTransaction();
// call to function that creates user
$user_id = create_user();
// call to function that creates company
$company_id = create_company();
// call to function to link user & company
add_user_to_company($user_id, $company_id);
$db->commit();
}
如果使用事务不能做到这一点,推荐的策略是什么?
【问题讨论】:
标签: php mysql transactions pdo