Source for file Firebird.php

Documentation is available at Firebird.php

  1. <?php
  2. /*
  3.  *  $Id: Firebird.php 1616 2007-06-10 19:17:26Z zYne $
  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_Import');
  22. /**
  23.  * @package     Doctrine
  24.  * @license     http://www.opensource.org/licenses/lgpl-license.php LGPL
  25.  * @author      Konsta Vesterinen <kvesteri@cc.hut.fi>
  26.  * @author      Lorenzo Alberton <l.alberton@quipo.it> (PEAR MDB2 Interbase driver)
  27.  * @author      Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
  28.  * @version     $Revision: 1616 $
  29.  * @category    Object Relational Mapping
  30.  * @link        www.phpdoctrine.com
  31.  * @since       1.0
  32.  */
  33. {
  34.     /**
  35.      * list all tables in the current database
  36.      *
  37.      * @return array        data array
  38.      */
  39.     public function listTables($database null)
  40.     {
  41.         $query 'SELECT RDB$RELATION_NAME FROM RDB$RELATIONS WHERE RDB$SYSTEM_FLAG=0 AND RDB$VIEW_BLR IS NULL';
  42.  
  43.         return $this->conn->fetchColumn($query);
  44.     }
  45.     /**
  46.      * list all fields in a tables in the current database
  47.      *
  48.      * @param string $table name of table that should be used in method
  49.      * @return mixed data array on success, a MDB2 error on failure
  50.      * @access public
  51.      */
  52.     public function listTableFields($table)
  53.     {
  54.         $table $this->conn->quote(strtoupper($table)'text');
  55.         $query 'SELECT RDB$FIELD_NAME FROM RDB$RELATION_FIELDS WHERE UPPER(RDB$RELATION_NAME) = ' $table;
  56.  
  57.         return $this->conn->fetchColumn($query);
  58.     }
  59.     /**
  60.      * list all users
  61.      *
  62.      * @return array            data array containing all database users
  63.      */
  64.     public function listUsers()
  65.     {
  66.         return $this->conn->fetchColumn('SELECT DISTINCT RDB$USER FROM RDB$USER_PRIVILEGES');
  67.     }
  68.     /**
  69.      * list the views in the database
  70.      *
  71.      * @return array            data array containing all database views
  72.      */
  73.     public function listViews($database null)
  74.     {
  75.         return $this->conn->fetchColumn('SELECT DISTINCT RDB$VIEW_NAME FROM RDB$VIEW_RELATIONS');
  76.     }
  77.     /**
  78.      * list the views in the database that reference a given table
  79.      *
  80.      * @param string $table     table for which all references views should be found
  81.      * @return array            data array containing all views for given table
  82.      */
  83.     public function listTableViews($table)
  84.     {
  85.         $query  'SELECT DISTINCT RDB$VIEW_NAME FROM RDB$VIEW_RELATIONS';
  86.         $table  $this->conn->quote(strtoupper($table)'text');
  87.         $query .= ' WHERE UPPER(RDB$RELATION_NAME) = ' $table;
  88.  
  89.         return $this->conn->fetchColumn($query);
  90.     }
  91.     /**
  92.      * list all functions in the current database
  93.      *
  94.      * @return array              data array containing all availible functions
  95.      */
  96.     public function listFunctions()
  97.     {
  98.         $query 'SELECT RDB$FUNCTION_NAME FROM RDB$FUNCTIONS WHERE RDB$SYSTEM_FLAG IS NULL';
  99.  
  100.         return $this->conn->fetchColumn($query);
  101.     }
  102.     /**
  103.      * This function will be called to get all triggers of the
  104.      * current database ($this->conn->getDatabase())
  105.      *
  106.      * @param  string $table      The name of the table from the
  107.      *                             previous database to query against.
  108.      * @return array              data array containing all triggers for given table
  109.      */
  110.     public function listTableTriggers($table)
  111.     {
  112.         $query 'SELECT RDB$TRIGGER_NAME FROM RDB$TRIGGERS WHERE RDB$SYSTEM_FLAG IS NULL OR RDB$SYSTEM_FLAG = 0';
  113.  
  114.         if is_null($table)) {
  115.             $table $this->conn->quote(strtoupper($table)'text');
  116.             $query .= ' WHERE UPPER(RDB$RELATION_NAME) = ' $table;
  117.         }
  118.  
  119.         return $this->conn->fetchColumn($query);
  120.     }
  121. }