简体   繁体   中英

PDO Alter table adding multiple columns SQLite

I want to add some columns in to existing database table after the last column i want to add these.. the scritp will be avalaible for everyone so not sure what will be the last column.

$DB_Column = array (
        'About_Me' => "About", 
        'Avatar' => "Avatar",
        'Clan_Tag' => "Clan",
        'Month' => "Month",
        'Day' => "Day",
        'Year' => "Year",
        'Website' => "Website",
        'Website_Link' => "Link",
        'Website_Link1' => "Link1",
        'Email_Address' => "Email"
    );

$Database->exec('ALTER TABLE '.$DB_Table.' 

            ADD COLUMN '.$DB_Column['About_Me'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Avatar'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Clan_Tag'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Month'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Day'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Year'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Website'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Website_Link'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Website_Link1'].' VARCHAR(255),
            ADD COLUMN '.$DB_Column['Email_Address'].' VARCHAR(255) 
    ');

Getting this error:

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near ",": syntax error' in C:\\xampp\\htdocs\\Webstats\\Functions.php:30 Stack trace: #0 C:\\xampp\\htdocs\\Webstats\\Functions.php(30): PDO->exec('ALTER TABLE RCO...') #1 C:\\xampp\\htdocs\\Webstats\\Index.php(3): require('C:\\xampp\\htdocs...') #2 {main} thrown in C:\\xampp\\htdocs\\Webstats\\Functions.php on line 30

ALTER TABLE语句仅允许一列。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM