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?

2
  • 1
    Your question has already been answered here : stackoverflow.com/questions/6346674/… Commented Sep 2, 2015 at 11:43
  • Oh, I missed that thread... Thanks Commented Sep 2, 2015 at 11:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.