Coverage for Doctrine_Connection_Sqlite

Back to coverage report

1 <?php
2 /*
3  *  $Id: Sqlite.php 2702 2007-10-03 21:43:22Z Jonathan.Wage $
4  *
5  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
6  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
7  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
8  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
9  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
10  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
11  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
12  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
13  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
14  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
15  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16  *
17  * This software consists of voluntary contributions made by many individuals
18  * and is licensed under the LGPL. For more information, see
19  * <http://www.phpdoctrine.com>.
20  */
21 Doctrine::autoload("Doctrine_Connection_Common");
22 /**
23  * Doctrine_Connection_Sqlite
24  *
25  * @package     Doctrine
26  * @subpackage  Connection
27  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
28  * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
29  * @author      Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
30  * @version     $Revision: 2702 $
31  * @link        www.phpdoctrine.com
32  * @since       1.0
33  */
34 class Doctrine_Connection_Sqlite extends Doctrine_Connection_Common
35 {
36     /**
37      * @var string $driverName                  the name of this connection driver
38      */
39     protected $driverName = 'Sqlite';
40     /**
41      * the constructor
42      *
43      * @param Doctrine_Manager $manager
44      * @param PDO $pdo                          database handle
45      */
46     public function __construct(Doctrine_Manager $manager, $adapter)
47     {
48
49         $this->supported = array(
50                           'sequences'            => 'emulated',
51                           'indexes'              => true,
52                           'affected_rows'        => true,
53                           'summary_functions'    => true,
54                           'order_by_text'        => true,
55                           'current_id'           => 'emulated',
56                           'limit_queries'        => true,
57                           'LOBs'                 => true,
58                           'replace'              => true,
59                           'transactions'         => true,
60                           'savepoints'           => false,
61                           'sub_selects'          => true,
62                           'auto_increment'       => true,
63                           'primary_key'          => true,
64                           'result_introspection' => false, // not implemented
65                           'prepared_statements'  => 'emulated',
66                           'identifier_quoting'   => true,
67                           'pattern_escaping'     => false,
68                           );
69         /**
70         $this->options['base_transaction_name'] = '___php_Doctrine_sqlite_auto_commit_off';
71         $this->options['fixed_float'] = 0;
72         $this->options['database_path'] = '';
73         $this->options['database_extension'] = '';
74         $this->options['server_version'] = '';
75         */
76         parent::__construct($manager, $adapter);
77
78         if ($this->isConnected) {
79             $this->dbh->sqliteCreateFunction('mod',    array('Doctrine_Expression_Sqlite', 'modImpl'), 2);
80             $this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl'));
81             $this->dbh->sqliteCreateFunction('md5', 'md5', 1);
82             $this->dbh->sqliteCreateFunction('now', 'time', 0);
83         }
84     }
85     /**
86      * initializes database functions missing in sqlite
87      *
88      * @see Doctrine_Expression
89      * @return void
90      */
91     public function connect() 
92     {
93         if ($this->isConnected) {
94             return false;
95         }
96
97         parent::connect();
98
99         $this->dbh->sqliteCreateFunction('mod',    array('Doctrine_Expression_Sqlite', 'modImpl'), 2);
100         $this->dbh->sqliteCreateFunction('concat', array('Doctrine_Expression_Sqlite', 'concatImpl'));
101         $this->dbh->sqliteCreateFunction('md5', 'md5', 1);
102         $this->dbh->sqliteCreateFunction('now', 'time', 0);
103     }
104     /**
105      * getDatabaseFile
106      *
107      * @param string $name      the name of the database
108      * @return string
109      */
110     public function getDatabaseFile($name)
111     {
112         return $name . '.db';
113     }
114 }