duanhe6799
duanhe6799
2018-02-05 12:25
浏览 83
已采纳

无法在PHP中为mySQL创建触发器

I am trying to create a trigger into mySQL using PHP

mysqli_select_db($host, "game");
$sql = "CREATE TRIGGER test_seven BEFORE INSERT ON test FOR EACH ROW INSERT INTO test (name) VALUES ('test')";
$query = $host->prepare($sql);
$query->execute();

And it is not working even though I tried running it on phpMyAdmin and it worked.

EDIT: "This command is not supported in the prepared statement protocol yet" Is there a way of skipping the prepare statement then ?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doubi4531
    doubi4531 2018-02-05 13:18
    已采纳

    Apparently the real problem was the fact that I was not supposed to use the PDO::prepare statement, if anyone else is having this issue use PDO::exec.

    点赞 评论

相关推荐