0

This query dies when I try to execute it in PHP code and in phpMyAdmin.

UPDATE Inventory 
INNER JOIN InventorySuppliers 
ON Inventory.LocalSKU = InventorySuppliers.LocalSKU 
SET Inventory.Integer2 = '1' 
WHERE InventorySuppliers.SupplierSKU = '2D4027A6'

The error is:

1205 - Lock wait timeout exceeded; try restarting transaction

How can I prevent the lock timeout and/or solve this problem?

I can run this query in Microsoft Access correctly, and phpMyAdmin db is a copy of that Access database. Increasing the execution time is not an option for me as that will take too long for one record update.

$data1 = array('Inventory.Integer2'=>$shipping);

$this->db->where('InventorySuppliers.SupplierSKU', $SupplierSKU);
$this->db->update('Inventory inner join InventorySuppliers  on Inventory.LocalSKU = InventorySuppliers.LocalSKU', $data1);
$this->db->close();
return ($this->db->affected_rows() > 0);
4

2 回答 2

0

好吧...对我来说很有趣...正如我告诉过你的,我的 SQL 数据库是来自 ms access db 的副本...不知道发生了什么,但是 mysql 数据库表没有主键或索引,尽管原始数据库有它们。 ..我尝试分配 PK 和索引,但 mysql 返回错误,我的最终解决方案是

  • 删除mysql中的表
  • 确保 PK 在表结构中分配(在我的情况下,从 MS-Access 导入后,我必须再做一次)
  • 检查索引字段(我有一个字段索引),并确保索引存在

这对我有用,现在相同的查询运行正常......

感谢所有人的帮助...希望这两个步骤将来可能对某人有所帮助...

于 2013-10-29T18:43:48.250 回答
0

在运行您的UPDATE.

SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
于 2013-10-24T21:16:12.700 回答