~ubuntu-branches/debian/squeeze/movabletype-opensource/squeeze

« back to all changes in this revision

Viewing changes to php/lib/mtdb_pdo_sqlite.php

  • Committer: Bazaar Package Importer
  • Author(s): Dominic Hargreaves
  • Date: 2008-06-13 23:28:40 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080613232840-ya4jfxv1jgl45a3d
Tags: 4.2~rc2-1
* New upstream release candidate
* Update Standards-Version (no changes)
* Ensure that schema upgrade message is always seen

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
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.
 
5
#
 
6
# $Id$
 
7
 
 
8
require_once("ezsql".DIRECTORY_SEPARATOR."ezsql_pdo_sqlite.php");
 
9
require_once("mtdb_sqlite.php");
 
10
 
 
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);
 
15
    }
 
16
 
 
17
    function query_start($query)
 
18
    {
 
19
        // For reg expressions
 
20
        $query = trim($query); 
 
21
 
 
22
        // Query was an insert, delete, update, replace
 
23
        if ( preg_match("/^(insert|delete|update|replace)\s+/i",$query) )
 
24
        {
 
25
            return false;
 
26
        }
 
27
 
 
28
        $this->savedqueries[] = $query;
 
29
 
 
30
        // Flush cached values..
 
31
        $this->flush();
 
32
 
 
33
        // Log how the function was called
 
34
        $this->func_call = "\$db->query_start(\"$query\")";
 
35
 
 
36
        // Keep track of the last query for debug..
 
37
        $this->last_query = $query;
 
38
 
 
39
        $this->result = $this->dbh->query($query);
 
40
        $this->num_queries++;
 
41
 
 
42
        // If there is an error then take note of it..
 
43
        if ( !$this->result )
 
44
        {
 
45
            $this->print_error();
 
46
            return false;
 
47
        }
 
48
        
 
49
        // =======================================================
 
50
        // Take note of column info
 
51
 
 
52
        #$i=0;
 
53
        #foreach(@sqlite_fetch_field_array($handle) as $name)
 
54
        #{
 
55
        #   $this->col_info[$i++]->name = $name;
 
56
        #}
 
57
 
 
58
        $this->last_result = array();
 
59
        $this->num_rows = 0;
 
60
     
 
61
        // If debug ALL queries
 
62
        $this->trace || $this->debug_all ? $this->debug() : null ;
 
63
 
 
64
        return true;
 
65
    }
 
66
 
 
67
    function query_fetch($output=OBJECT) {
 
68
        if ( $row = $this->result->fetch(PDO::FETCH_ASSOC) )
 
69
        {
 
70
            $row = (Object) $row;
 
71
            $this->num_rows++;
 
72
 
 
73
            if ( $output == OBJECT )
 
74
            {
 
75
                return $row;
 
76
            }
 
77
            // If the output is an associative array then return row as such..
 
78
            elseif ( $output == ARRAY_A )
 
79
            {
 
80
                return $row ? $this->convert_fieldname(get_object_vars($row)) : null;
 
81
            }
 
82
            // If the output is an numerical array then return row as such..
 
83
            elseif ( $output == ARRAY_N )
 
84
            {
 
85
                return $row ? array_values(get_object_vars($row)) : null;
 
86
            }
 
87
        }
 
88
        return null;
 
89
    }
 
90
}
 
91
?>