10.06.2017, 20:58
I have 2 tables
I use FOREIGN KEY (ID_USER) REFERENCES CUENTA(ID) ON DELETE CASCADE
When execute 'DELETE FROM `CUENTA` WHERE `ID` = 'x';' only delete record from CUENTA table but record is not deleted on REGISTRO table.
Is this possible in sqlite?
PHP код:
/* CUENTA */
format(DB_Query, sizeof(DB_Query),
"\
CREATE TABLE IF NOT EXISTS `CUENTA`\
(\
`ID` INTEGER PRIMARY KEY AUTOINCREMENT,\
`IP` VARCHAR(16),\
`NAME` VARCHAR(24),\
`EMAIL` VARCHAR(32),\
`PASS` INTEGER,\
`LAST_CONNECTION` VARCHAR(24) DEFAULT CURRENT_TIMESTAMP,\
`LAST_CONNECTION_TIMESTAMP` INTEGER DEFAULT '0',\
`TIME-PLAYING` INTEGER DEFAULT '0',\
`LEVEL` INTEGER DEFAULT '1',\
`REP` INTEGER DEFAULT '1',\
`STATE` INTEGER DEFAULT '0'\
);\
");
db_query(Database, DB_Query);
/* REGISTRO */
format(DB_Query, sizeof(DB_Query),
"\
CREATE TABLE IF NOT EXISTS `REGISTRO`\
(\
`ID_USER` INTEGER,\
`IP` VARCHAR(16),\
`NAME` VARCHAR(24),\
`EMAIL` VARCHAR(32),\
`PASS` INTEGER,\
`DATE` VARCHAR(24) DEFAULT CURRENT_TIMESTAMP,\
FOREIGN KEY (ID_USER) REFERENCES CUENTA(ID) ON DELETE CASCADE\
);\
");
db_query(Database, DB_Query);
When execute 'DELETE FROM `CUENTA` WHERE `ID` = 'x';' only delete record from CUENTA table but record is not deleted on REGISTRO table.
Is this possible in sqlite?