open('database.db'); $sql = " CREATE TABLE IF NOT EXISTS users ( ID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, HANDLE TEXT NOT NULL UNIQUE, NAME TEXT NOT NULL, ABOUT TEXT NOT NULL ); CREATE TABLE IF NOT EXISTS posts ( ID INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE, TIME INTEGER NOT NULL, USERID INTEGER NOT NULL, TEXT TEXT NOT NULL ); INSERT OR IGNORE INTO users (ID, HANDLE, NAME, ABOUT) VALUES ('0', 'SYSTEM', 'SYSTEM', ''); "; $ret = $this->exec($sql); } function addUser($handle, $name, $about="") { $sql = "INSERT INTO users (HANDLE, NAME, ABOUT) VALUES ('$handle', '$name', '$about')"; $ret = $this->exec($sql); if(!$ret) { die($this->lastErrorMsg()); } } function addPost($contents) { $userid = 0; $time = time(); $sql = "INSERT INTO posts (TIME, USERID, TEXT) values ('$time', '$userid', '$contents')"; $ret = $this->exec($sql); if(!$ret) { die($this->lastErrorMsg()); } } } ?>