Thread: SQLite
View Single Post
  #39  
Old 04-13-2009, 03:10 AM
LoneAngelIbesu LoneAngelIbesu is offline
master of infinite loops
LoneAngelIbesu's Avatar
Join Date: May 2007
Location: Toldeo, Ohio
Posts: 1,049
LoneAngelIbesu has a spectacular aura aboutLoneAngelIbesu has a spectacular aura about
Send a message via AIM to LoneAngelIbesu
Quote:
Originally Posted by Damix2 View Post
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.rowtemp.sqltest.rows) {
    echo(
"Title: " temp.row.title);
    for(
temp.irowtemp.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(queryisreq) {
  
temp.req requestsql(temp.querytemp.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;

__________________
"We are all in the gutter, but some of us are looking at the stars."
— Oscar Wilde, Lady Windermere's Fan
Reply With Quote