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?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Mehmet Ekici
  • 1
  • 1
  • 4

1 Answers1

0

ezSQL does not support running multiple statements in a single query. Each statement must be executed in a separate query.

Original answer:

Run just one SQL statement.

MariaDB supports multirow insert with VALUES clause...

  INSERT INTO chart_logs (chart_id, uname, option_id) VALUES
    ('1', '1', '1')
  , ('2', '2', '2')
spencer7593
  • 106,611
  • 15
  • 112
  • 140
  • Thanks it works, but same error DELETE query line 1? INSERT INTO chart_logs (chart_id, uname, option_id) VALUES ('1', '1', '1'); DELETE FROM chart_logs where chart_id = 3; – Mehmet Ekici Mar 31 '17 at 17:01
  • As I said in the answer... run just *one* SQL statement in a query. That means the sql text should have *one* INSERT statement, or *one* DELETE statement. ( *ezSQL* does not support running multiple statements in a single query.) – spencer7593 Mar 31 '17 at 19:03