在数据库上创建多个表

时间:2012-08-15 13:15:42

标签: php database pdo

使用PHP在包含数据库的$fsdbh的数据库上创建表。显然我错过了一些东西。

function createdb($tables){
    global $fsdbh;
    $sth = $fsdbh->prepare('CREATE TABLE IF NOT EXISTS system');
    $sth->execute();
}

此功能在触发时会导致黑屏。

目的是使用该函数创建一系列表格:

function createdb($tables){
    global $fsdbh;
    $sql = 'CREATE TABLE IF NOT EXISTS system';
    foreach($tables as $table){
       $sql.= '; CREATE TABLE IF NOT EXISTS $table';
    }
    $sth = $fsdbh->prepare($sql);
    $sth->execute();
}

我们如何让它发挥作用?

0 个答案:

没有答案