示例#1
0
function DB_Create_Table()
{
    global $db, $DB_TableName;
    $Query = 'CREATE TABLE ' . $DB_TableName . ' (id MEDIUMINT AUTO_INCREMENT NOT NULL, word VARCHAR (30) BINARY NOT NULL, sound VARCHAR(10) not NULL, PRIMARY KEY(id), INDEX(sound), UNIQUE(word))';
    $result = mysql_query($Query, $db);
    if (!$result) {
        $Info = DB_Error_Message($result);
        if ($Info != '1050') {
            echo 'Unable to create dictionary database table: ' . $Info;
        }
    }
}
示例#2
0
function DB_Create_Table()
{
    global $dbms, $db, $DB_TableName;
    switch ($dbms) {
        case 'mysql':
        case 'mysql4':
            $Query[0] = 'CREATE TABLE ' . $DB_TableName . ' (id MEDIUMINT AUTO_INCREMENT NOT NULL, word VARCHAR (30) BINARY NOT NULL, sound VARCHAR(10) not NULL, PRIMARY KEY(id), INDEX(sound), UNIQUE(word))';
            break;
        case 'mssql-odbc':
        case 'mssql':
            $Query[0] = 'CREATE TABLE [' . $DB_TableName . '] ([id] [int] primary key identity (1,1) NOT NULL , [word] [varchar] (30) NOT NULL, [sound] [varchar] (10) NOT NULL) ON [PRIMARY]';
            //        $Query[0] = 'CREATE TABLE ['.$DB_TableName.'] ([id] [int] NOT NULL , [word] [varchar] (30) NOT NULL, [sound] [varchar] (10) NOT NULL) ON [PRIMARY]';
            $Query[1] = 'CREATE INDEX [IX_' . $DB_TableName . '_WORD] on [' . $DB_TableName . '](word) ON [PRIMARY]';
            $Query[2] = 'CREATE INDEX [IX_' . $DB_TableName . '_SOUND] on [' . $DB_TableName . '](sound) ON [PRIMARY]';
            break;
        default:
            message_die(CRITICAL_ERROR, 'No valid SQL to create your database type.');
    }
    for ($i = 0; $i < count($Query); $i++) {
        $result = $db->sql_query($Query[$i]);
        if (!$result) {
            $Info = DB_Error_Message($result);
            if ($Info != '1050') {
                echo 'Unable to create dictionary database table: ' . $Info;
            }
        }
    }
}