00001 <?php
00013 class DB_SQLite3 extends DB_Base
00014 {
00015 function DB_SQLite3($conn, $persistent) {
00016 $this->safesql = new SafeSQL_ANSI;
00017 $this->type = 'sqlite3';
00018
00019 $this->conn = new SQLite3($conn['file']);
00020
00021 if(!$this->conn) {
00022 $this->_catch("Unable to connect to the database!");
00023 return false;
00024 }
00025
00026 return true;
00027 }
00028
00029 function _catch($msg="") {
00030 if(!$this->error = $this->conn->lastErrorMsg()) return true;
00031 $this->error($msg."<br>{$this->query}\n {$this->error}");
00032 }
00033
00034 function get_table_defn($table) {
00035 return false;
00036 }
00037
00038 function run_query($sql) {
00039 return $this->conn->query($sql);
00040 }
00041
00042 function fetch_row(&$q) {
00043 return $q->fetchArray(SQLITE3_NUM);
00044 }
00045
00046 function fetch_array(&$q) {
00047 return $q->fetchArray(SQLITE3_ASSOC);
00048 }
00049
00050 function fetch_field(&$q, $num) {
00051 $a = $this->fetch_row($q);
00052 return $a[$num];
00053 }
00054
00055 function num_fields(&$q) {
00056 return $q->numColumns();
00057 }
00058
00059 function num_rows(&$q) {
00060
00061
00062
00063 $ct = 0;
00064 while($row = $q->fetchArray(SQLITE3_NUM)) $ct++;
00065 $q->reset();
00066 return $ct;
00067 }
00068
00069 function get_insert_id() {
00070 return $this->conn->lastInsertRowID();
00071 }
00072
00073 function free_result($q) {
00074 return true;
00075 }
00076 }
00077
00078 ?>