0

I'm working on a project with multiple tables. All of those tables have a create table if not exists in a file named database.sql.

I wanted to execute this file containing severals create table in PDO. The problem is that it only execute the first create table of the file.

Here is my code:

<?php

$sql = file_get_contents(__DIR__ . self::PATH_DATABASE_FILE);

$this->mPdoConnection->exec($sql);

And my sql:

/***************
 * Command
 ***************/
CREATE TABLE IF NOT EXISTS command (
  command_word       VARCHAR(64)  NOT NULL PRIMARY KEY,
  command_answer     VARCHAR(128) NOT NULL,
  command_level      INT          NOT NULL DEFAULT 3,
  command_createtime INT          NOT NULL
);

/***************
 * Preference
 ***************/
CREATE TABLE IF NOT EXISTS preference (
  preference_name  VARCHAR(64) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  preference_value VARCHAR(32) NOT NULL
);

Is this a syntaxe issue unsupported by PDO or simply that PDO doesn't support more than one request?

0 Answers0