특정 오류 작동하지 :여러 인서트는 PHP의 PDO와 SQLite는 DB를 사용하여, SQLite는 3
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 near ",": syntax error' in D:\Projects\2013\Stat collection plugin\stats\htdocs\index.php:8 Stack trace: #0 D:\Projects\2013\Stat collection plugin\stats\htdocs\index.php(8): PDO->exec('CREATE TABLE IF...') #1 {main} thrown in D:\Projects\2013\Stat collection plugin\stats\htdocs\index.php on line 8
코드를 :
$dbSchema = file_get_contents('../schema.sql');
$PDO = new PDO('sqlite:../stats.db');
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$PDO->exec($dbSchema);
가 여기 내 스키마입니다. 내가 처음에 CREATE TABLE 문을 가지고있을 때 오류가있는 것 같지만 다음 문장에서 같은 오류가 발생했다면 알려 주시면 고맙겠습니다. 미리 감사드립니다!
CREATE TABLE IF NOT EXISTS game (
id INTEGER PRIMARY KEY AUTOINCREMENT,
serverName STRING NOT NULL,
map STRING NOT NULL,
winner INTEGER NOT NULL,
gameMode STRING NOT NULL,
controlPoints INTEGER,
setupGate BOOLEAN,
capsRed INTEGER,
capsBlue INTEGER,
winsRed INTEGER,
winsBlue INTEGER,
CONSTRAINT game_winner_teamTypes_id FOREIGN KEY (winner) REFERENCES teamTypes(id)
);
CREATE TABLE IF NOT EXISTS player (
id INTEGER PRIMARY KEY AUTOINCREMENT,
gameId INTEGER NOT NULL,
name STRING NOT NULL,
team INTEGER NOT NULL,
class INTEGER NOT NULL,
queueJump BOOLEAN NOT NULL,
CONSTRAINT player_gameId_game_id FOREIGN KEY (gameId) REFERENCES game(id),
CONSTRAINT player_team_teamTypes_id FOREIGN KEY (team) REFERENCES teamTypes(id),
CONSTRAINT player_class_classTypes_id FOREIGN KEY (class) REFERENCES classTypes(id)
);
CREATE TABLE IF NOT EXISTS stat (
playerId INTEGER NOT NULL,
type INTEGER NOT NULL,
value INTEGER NOT NULL,
CONSTRAINT stat_playerId_player_id FOREIGN KEY (playerId) REFERENCES player(id),
CONSTRAINT stat_type_statTypes_id FOREIGN KEY (type) REFERENCES statTypes(id)
);
CREATE TABLE IF NOT EXISTS teamTypes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name STRING NOT NULL
);
INSERT OR IGNORE INTO teamTypes(id, name) VALUES (0, 'Red'), (1, 'Blue'), (2, 'Spectator');
CREATE TABLE IF NOT EXISTS classTypes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name STRING NOT NULL
);
INSERT OR IGNORE INTO classTypes(id, name) VALUES (0, 'Runner'), (1, 'Rocketman'), (2, 'Rifleman'), (3, 'Detonator'), (4, 'Healer'), (5, 'Constructor'), (6, 'Overweight'), (7, 'Infiltrator'), (8, 'Firebug'), (9, 'Querly');
CREATE TABLE IF NOT EXISTS statTypes (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name STRING NOT NULL
);
INSERT OR IGNORE INTO statTypes(id, name) VALUES (0, 'Kills'), (1, 'Deaths'), (2, 'Caps'), (3, 'Assists'), (4, 'Destruction'), (5, 'Stabs'), (6, 'Healing'), (7, 'Defenses'), (8, 'Invulns'), (9, 'Bonus'), (10, 'Dominations'), (11, 'Revenge'), (12, 'Points');
나를 위해 완벽하게 작동합니다. http://sqlfiddle.com/#!5/fe303 – fancyPants
흠 ... 아마 PHP와 PDO를 사용하여 저와 관련이 있습니까? '치명적 오류 : D : \ Projects \ 2013 \ Stat 콜렉션 플러그인 \ 통계 \ htdocs \ index.php에'SQLSTATE [HY000] : 일반 오류 : 1 근처에 ":"구문 오류 "메시지가있는 'PDOException'오류가 발생했습니다. : 8 스택 추적 : # 0 D : \ Projects \ 2013 \ Stat 컬렉션 플러그인 \ stats \ htdocs \ index.php (8) : PDO-> exec ('CREATE TABLE IF ...') # 1 {main} throw D : \ Projects \ 2013 \ Stat 컬렉션 플러그인 \ stats \ htdocs \ index.php on line 8' – Andrea
이것을 반영하기 위해 편집 된 질문입니다. – Andrea