我必须在模型上运行该SQL例程:如何用codeigniter锁定表格?
$this->db->query('LOCK TABLE orders WRITE');
$this->db->query('TRUNCATE TABLE orders');
$this->db->query('INSERT INTO orders SELECT * FROM orders_tmp');
$this->db->query('UNLOCK TABLES');
,但我得到这个错误:
Error Number: 1192
Impossible to execute the requested command: tables under lock or transaction running
TRUNCATE TABLE orders
我使用MyISAM作为DB引擎上此表。
你能帮我吗?
这篇文章可以帮助你。 http://stackoverflow.com/questions/1951161/mysql-myisam-table-locking – 2012-07-18 12:21:51
遗憾的是它不工作!第一条SQL我做的是:“LOCK TABLES命令WRITE,orders_tmp写”,但我得到一个错误,从CI,指出台的订单没有被锁定... :( – user1534715 2012-07-18 15:30:50
它始终是更好地使用InnoDB引擎,而使用的表或行级锁定。不管怎么说,我会尽力尽快给您更具体的答案。谢谢 – 2012-07-19 04:00:49