Jeroen De Dauw
Jeroen De Dauw

Reputation: 10908

PDO+SQLite does not run multiple statements in one query?

I'm running the following SQL using PDO+SQLite:

CREATE TABLE default_field_values (intfield INT NOT NULL, floatfield FLOAT NOT NULL, boolfield TINYINT NOT NULL);
CREATE INDEX somename ON default_field_values (intfield,floatfield);

When feeding this to the PDO::query method, a table gets created, but it ends up not having an index. When running the SQL via the sqlite3 CLI, it works as intended. The issue also does not occur when running MySQL.

Upvotes: 2

Views: 1331

Answers (1)

CL.
CL.

Reputation: 180060

The documentation says:

PDO::query() executes an SQL statement

And it did indeed execute an SQL statement.

PDO is not the CLI. If you want to execute multiple statements, use multiple query calls.

Upvotes: 1

Related Questions