2
# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
3
# This program is distributed under the terms of the
4
# GNU General Public License, version 2.
8
require_once("ezsql".DIRECTORY_SEPARATOR."ezsql_pdo_sqlite.php");
9
require_once("mtdb_sqlite.php");
11
class MTDatabase_pdo_sqlite extends MTDatabase_sqlite {
12
var $vendor = 'pdo_sqlite';
13
function MTDatabase_pdo_sqlite($dbuser, $dbpassword, $dbname, $dbhost, $dbport) {
14
parent::MTDatabaseBase($dbname);
17
function query_start($query)
19
// For reg expressions
20
$query = trim($query);
22
// Query was an insert, delete, update, replace
23
if ( preg_match("/^(insert|delete|update|replace)\s+/i",$query) )
28
$this->savedqueries[] = $query;
30
// Flush cached values..
33
// Log how the function was called
34
$this->func_call = "\$db->query_start(\"$query\")";
36
// Keep track of the last query for debug..
37
$this->last_query = $query;
39
$this->result = $this->dbh->query($query);
42
// If there is an error then take note of it..
49
// =======================================================
50
// Take note of column info
53
#foreach(@sqlite_fetch_field_array($handle) as $name)
55
# $this->col_info[$i++]->name = $name;
58
$this->last_result = array();
61
// If debug ALL queries
62
$this->trace || $this->debug_all ? $this->debug() : null ;
67
function query_fetch($output=OBJECT) {
68
if ( $row = $this->result->fetch(PDO::FETCH_ASSOC) )
73
if ( $output == OBJECT )
77
// If the output is an associative array then return row as such..
78
elseif ( $output == ARRAY_A )
80
return $row ? $this->convert_fieldname(get_object_vars($row)) : null;
82
// If the output is an numerical array then return row as such..
83
elseif ( $output == ARRAY_N )
85
return $row ? array_values(get_object_vars($row)) : null;