mz

thinkphp5执行复杂sql错误 query execute 锁表错误

主要是设置options 的PDO配置,因为原来的框架本身设置,导致锁表报错.

 

$options = Config::get(‘database’);
$options[‘params’] = [
\PDO::ATTR_CASE => \PDO::CASE_NATURAL,
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
\PDO::ATTR_ORACLE_NULLS => \PDO::NULL_NATURAL,
\PDO::ATTR_STRINGIFY_FETCHES => false,
\PDO::ATTR_EMULATE_PREPARES => true,
];
$db_instance = Db::connect($options);
$db_instance->execute(‘lock table interface read’);
$db_instance->execute(‘LOCK TABLES interface WRITE’);
sleep(10);
$db_instance->execute(‘UNLOCK tables’);

码字很辛苦,转载请注明来自明志博客《thinkphp5执行复杂sql错误 query execute 锁表错误》

评论