Source for file Firebird.php

Documentation is available at Firebird.php

  1. <?php
  2. /*
  3.  *  $Id: Firebird.php 1080 2007-02-10 18:17:08Z romanb $
  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.  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
  27.  * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
  28.  * @author      Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
  29.  * @author      Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
  30.  * @version     $Revision: 1080 $
  31.  * @category    Object Relational Mapping
  32.  * @link        www.phpdoctrine.com
  33.  * @since       1.0
  34.  */
  35. {
  36.     /**
  37.      * @var string $driverName                  the name of this connection driver
  38.      */
  39.     protected $driverName = 'Firebird';
  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'             => true,
  51.                           'indexes'               => true,
  52.                           'affected_rows'         => true,
  53.                           'summary_functions'     => true,
  54.                           'order_by_text'         => true,
  55.                           'transactions'          => true,
  56.                           'savepoints'            => true,
  57.                           'current_id'            => true,
  58.                           'limit_queries'         => 'emulated',
  59.                           'LOBs'                  => true,
  60.                           'replace'               => 'emulated',
  61.                           'sub_selects'           => true,
  62.                           'auto_increment'        => true,
  63.                           'primary_key'           => true,
  64.                           'result_introspection'  => true,
  65.                           'prepared_statements'   => true,
  66.                           'identifier_quoting'    => false,
  67.                           'pattern_escaping'      => true
  68.                           );
  69.         // initialize all driver options
  70.         /**
  71.         $this->options['DBA_username'] = false;
  72.         $this->options['DBA_password'] = false;
  73.         $this->options['database_path'] = '';
  74.         $this->options['database_extension'] = '.gdb';
  75.         $this->options['server_version'] = '';
  76.         */
  77.         parent::__construct($manager$adapter);
  78.     }
  79.     /**
  80.      * Set the charset on the current connection
  81.      *
  82.      * @param string    charset
  83.      *
  84.      * @return void 
  85.      */
  86.     public function setCharset($charset)
  87.     {
  88.         $query 'SET NAMES '.$this->dbh->quote($charset);
  89.         $this->exec($query);
  90.     }
  91.     /**
  92.      * Adds an driver-specific LIMIT clause to the query
  93.      *
  94.      * @param string $query     query to modify
  95.      * @param integer $limit    limit the number of rows
  96.      * @param integer $offset   start reading from given offset
  97.      * @return string modified  query
  98.      */
  99.     public function modifyLimitQuery($query$limit$offset)
  100.     {
  101.         if ($limit 0{
  102.             $query preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',
  103.                 "SELECT FIRST $limit SKIP $offset"$query);
  104.         }
  105.         return $query;
  106.     }
  107. }