/ Published in: PHP
Expand |
Embed | Plain Text
/* * Description: Very simple and lightweight SQLite wrapper class, it also has some SQL injection protection. * License: Competely public domain with no warranty whatsoever. */ Class SQLiteDB { private $db; private $debug = true; var $argChar = '?'; // For debugging purposes. var $statement; function __construct($filename = null) { $this->open($filename); } function open($filename = null) { // If no file is specified create a temporary table in memory. $filename = ':memory:'; if (!$this->db = sqlite_open($filename, 0666, $sqliteerror)) } function execute($statement, $arguments = null) { } } // For debugging purposes. if ($debug) { $this->statement = $statement; $this->old_statements[] = $statement; } $rs = sqlite_query($this->db, $this->statement); return new ResultSet($rs); } function close() { sqlite_close($this->db); } function lastInsertRowId() { return sqlite_last_insert_rowid($db); } } Class ResultSet { private $rs; function __construct($rs) { $this->rs = $rs; } function isValidRow() { return sqlite_valid($this->rs); } return sqlite_next($this->rs); } function fieldCount() { $row = sqlite_current($this->rs); } function fieldName($fieldIndex) { return sqlite_field_name($this->rs, $fieldIndex); } function field($fieldIndex) { $row = sqlite_current($this->rs); } }
You need to login to post a comment.
