Quote:
Originally Posted by Damix2
As for your error? No, not really, at least not that I can see. The fact that SQLite doesn't support referential integrity is surprising I'd say. Also no outer joins (granted, that can be accomplished in other ways.)
|
Using requestsql2() pointing to the "sqlite_master" database results in no error. However, when trying to access the data, nothing is outputted.
PHP Code:
sql.execute(
"CREATE TABLE IF NOT EXISTS shops ("
@ "title TEXT NOT NULL DEFAULT 'Shop', "
@ "stype TEXT NOT NULL DEFAULT 'Server', "
@ "owner TEXT NOT NULL DEFAULT 'Unknown', "
@ "kerou INT NOT NULL DEFAULT 5000, "
@ "desc TEXT NOT NULL DEFAULT 'Description text.', "
@ "createtime INT NOT NULL DEFAULT CURRENT_TIMESTAMP)", false);
requestsql2("sqlite_master",
"CREATE TABLE IF NOT EXISTS shops.items ("
@ "arch TEXT NOT NULL DEFAULT 'Unknown', "
@ "price INT DEFAULT 0, "
@ "stock INT DEFAULT 0)", false);
sql.execute(format(
"INSERT INTO shops VALUES('%s','%s','%s',%s,'%s',%s)",
"Test Shop", "Server", "NPCServer", 5000, "Description text.", "CURRENT_TIMESTAMP"), false);
requestsql2("sqlite_master",
"INSERT INTO shops.items VALUES('arch1',1000,10)", false);
temp.sqltest = sql.execute("SELECT * FROM shops WHERE title='Test Shop'", true);
for(temp.row: temp.sqltest.rows) {
echo("Title: " @ temp.row.title);
for(temp.irow: temp.row.items) { //I've also tried temp.row.items.rows
echo(temp.irow.arch @ ": " @ temp.irow.stock);
}
}
The execute() command is a simple error checker:
PHP Code:
public function execute(query, isreq) {
temp.req = requestsql(temp.query, temp.isreq);
if (temp.req.error != "") {
echo("SQL Error: " @ temp.req.error);
echo(" Query: " @ temp.query);
}
if (temp.isreq && !temp.req.completed &&
!waitfor(temp.req, "onReceiveData", 5))
return null;
return temp.req;
}