Coverage for Doctrine_Connection_Firebird

Back to coverage report

1 <?php
2 /*
3  *  $Id: Firebird.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');
22 /**
23  * Doctrine_Connection_Firebird
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  * @author      Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
31  * @version     $Revision: 2702 $
32  * @link        www.phpdoctrine.com
33  * @since       1.0
34  */
35 class Doctrine_Connection_Firebird extends Doctrine_Connection
36 {
37     /**
38      * @var string $driverName                  the name of this connection driver
39      */
40     protected $driverName = 'Firebird';
41     /**
42      * the constructor
43      *
44      * @param Doctrine_Manager $manager
45      * @param PDO $pdo                          database handle
46      */
47     public function __construct(Doctrine_Manager $manager, $adapter)
48     {
49
50         $this->supported = array(
51                           'sequences'             => true,
52                           'indexes'               => true,
53                           'affected_rows'         => true,
54                           'summary_functions'     => true,
55                           'order_by_text'         => true,
56                           'transactions'          => true,
57                           'savepoints'            => true,
58                           'current_id'            => true,
59                           'limit_queries'         => 'emulated',
60                           'LOBs'                  => true,
61                           'replace'               => 'emulated',
62                           'sub_selects'           => true,
63                           'auto_increment'        => true,
64                           'primary_key'           => true,
65                           'result_introspection'  => true,
66                           'prepared_statements'   => true,
67                           'identifier_quoting'    => false,
68                           'pattern_escaping'      => true
69                           );
70         // initialize all driver options
71         /**
72         $this->options['DBA_username'] = false;
73         $this->options['DBA_password'] = false;
74         $this->options['database_path'] = '';
75         $this->options['database_extension'] = '.gdb';
76         $this->options['server_version'] = '';
77         */
78         parent::__construct($manager, $adapter);
79     }
80     /**
81      * Set the charset on the current connection
82      *
83      * @param string    charset
84      *
85      * @return void
86      */
87     public function setCharset($charset)
88     {
89         $query = 'SET NAMES '.$this->dbh->quote($charset);
90         $this->exec($query);
91     }
92     /**
93      * Adds an driver-specific LIMIT clause to the query
94      *
95      * @param string $query     query to modify
96      * @param integer $limit    limit the number of rows
97      * @param integer $offset   start reading from given offset
98      * @return string modified  query
99      */
100     public function modifyLimitQuery($query, $limit, $offset)
101     {
102         if ($limit > 0) {
103             $query = preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',
104                 "SELECT FIRST $limit SKIP $offset", $query);
105         }
106         return $query;
107     }
108 }