gpt4 book ai didi

php - 通过 PHP 向 MySQL 添加触发器

转载 作者:太空宇宙 更新时间:2023-11-03 12:19:47 26 4
gpt4 key购买 nike

我使用 PhpMyAdmin 运行以下 SQL 语句。

CREATE TRIGGER `insert_channel_test2` AFTER DELETE ON `channel_test2` FOR EACH ROW INSERT INTO `tv`.`LOG_test2` (`table_name`, `table_action`) VALUES('channel_test2', 'delete');    

运行成功,但是当我使用PHP网页查询上面的代码时,出现Fatal error。

$query = "CREATE TRIGGER `insert_channel_test2` AFTER DELETE ON `channel_test2` FOR EACH ROW INSERT INTO `tv`.`LOG_test2` (`table_name`, `table_action`) VALUES('channel_test2', 'delete');"
$this->link = new mysqli( DB_HOST, DB_USER, DB_PASS, DB_NAME );
$full_query = $this->link->multi_query( $query );

错误信息如下。

 Commands out of sync; you can't run this command now

大家知道是什么问题吗?谢谢!

最佳答案

根据 MySQL:

C.5.2.14. Commands out of syncIf you get Commands out of sync; you can't run this command now in your client code,you are calling client functions in the wrong order.

This can happen, for example, if you are using mysql_use_result() and try to execute a new query before you have called mysql_free_result(). It can also happen if you try to execute two queries that return data without calling mysql_use_result() or mysql_store_result() in between.

引用:

关于php - 通过 PHP 向 MySQL 添加触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20630016/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com