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