0

I have a problem in ezSQL.

Code:

$dbo->query("INSERT INTO chart_logs (chart_id, uname, option_id) VALUES ('1', '1', '1'); INSERT INTO chart_logs (chart_id, uname, option_id) VALUES ('2', '2', '2'); ");

Error:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'INSERT INTO chart_logs (chart_id, uname, option_id) VALUES ('2', '2', '2')' at line 1

But,

This Sql Query works phpmyadmin SQL Command successfully. I dont understand this. Why sql code doesnt work in ezsql query?

4

1 回答 1

0

ezSQL 不支持在单个查询中运行多个语句。每个语句必须在单独的查询中执行。

原答案:

只运行一条SQL 语句。

MariaDB 支持带 VALUES 子句的多行插入...

  INSERT INTO chart_logs (chart_id, uname, option_id) VALUES
    ('1', '1', '1')
  , ('2', '2', '2')
于 2017-03-31T16:48:24.230 回答