Source for file Sqlite.php

Documentation is available at Sqlite.php

  1. <?php
  2. /*
  3.  *  $Id: Sqlite.php 2285 2007-08-29 19:07:43Z jackbravo $
  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.  * @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.  * @version     $Revision: 2285 $
  30.  * @category    Object Relational Mapping
  31.  * @link        www.phpdoctrine.com
  32.  * @since       1.0
  33.  */
  34. {
  35.     /**
  36.      * @var string $driverName                  the name of this connection driver
  37.      */
  38.     protected $driverName = 'Sqlite';
  39.     /**
  40.      * the constructor
  41.      *
  42.      * @param Doctrine_Manager $manager 
  43.      * @param PDO $pdo                          database handle
  44.      */
  45.     public function __construct(Doctrine_Manager $manager$adapter)
  46.     {
  47.  
  48.         $this->supported = array(
  49.                           'sequences'            => 'emulated',
  50.                           'indexes'              => true,
  51.                           'affected_rows'        => true,
  52.                           'summary_functions'    => true,
  53.                           'order_by_text'        => true,
  54.                           'current_id'           => 'emulated',
  55.                           'limit_queries'        => true,
  56.                           'LOBs'                 => true,
  57.                           'replace'              => true,
  58.                           'transactions'         => true,
  59.                           'savepoints'           => false,
  60.                           'sub_selects'          => true,
  61.                           'auto_increment'       => true,
  62.                           'primary_key'          => true,
  63.                           'result_introspection' => false// not implemented
  64.                           'prepared_statements'  => 'emulated',
  65.                           'identifier_quoting'   => true,
  66.                           'pattern_escaping'     => false,
  67.                           );
  68.         /**
  69.         $this->options['base_transaction_name'] = '___php_Doctrine_sqlite_auto_commit_off';
  70.         $this->options['fixed_float'] = 0;
  71.         $this->options['database_path'] = '';
  72.         $this->options['database_extension'] = '';
  73.         $this->options['server_version'] = '';
  74.         */
  75.         parent::__construct($manager$adapter);
  76.     }
  77.     /**
  78.      * initializes database functions missing in sqlite
  79.      *
  80.      * @see Doctrine_Expression
  81.      * @return void 
  82.      */
  83.     public function connect(
  84.     {
  85.         parent::connect();
  86.  
  87.         $this->dbh->sqliteCreateFunction('mod',    array('Doctrine_Expression_Sqlite''modImpl')2);
  88.         $this->dbh->sqliteCreateFunction('concat'array('Doctrine_Expression_Sqlite''concatImpl'));
  89.         $this->dbh->sqliteCreateFunction('md5''md5'1);
  90.         $this->dbh->sqliteCreateFunction('now''time'0);
  91.     }
  92.     /**
  93.      * getDatabaseFile
  94.      *
  95.      * @param string $name      the name of the database
  96.      * @return string 
  97.      */
  98.     public function getDatabaseFile($name)
  99.     {
  100.         return $name '.db';
  101.     }
  102. }