MDB2
[ class tree: MDB2 ] [ index: MDB2 ] [ all elements ]

Source for file ibase.php

Documentation is available at ibase.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5                                                 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox,                 |
  6. // | Stig. S. Bakken, Lukas Smith, Frank M. Kromann, Lorenzo Alberton     |
  7. // | All rights reserved.                                                 |
  8. // +----------------------------------------------------------------------+
  9. // | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB  |
  10. // | API as well as database abstraction for PHP applications.            |
  11. // | This LICENSE is in the BSD license style.                            |
  12. // |                                                                      |
  13. // | Redistribution and use in source and binary forms, with or without   |
  14. // | modification, are permitted provided that the following conditions   |
  15. // | are met:                                                             |
  16. // |                                                                      |
  17. // | Redistributions of source code must retain the above copyright       |
  18. // | notice, this list of conditions and the following disclaimer.        |
  19. // |                                                                      |
  20. // | Redistributions in binary form must reproduce the above copyright    |
  21. // | notice, this list of conditions and the following disclaimer in the  |
  22. // | documentation and/or other materials provided with the distribution. |
  23. // |                                                                      |
  24. // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
  25. // | Lukas Smith nor the names of his contributors may be used to endorse |
  26. // | or promote products derived from this software without specific prior|
  27. // | written permission.                                                  |
  28. // |                                                                      |
  29. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
  30. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
  31. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
  32. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
  33. // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
  34. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  35. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
  36. // |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
  37. // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
  38. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
  39. // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
  40. // | POSSIBILITY OF SUCH DAMAGE.                                          |
  41. // +----------------------------------------------------------------------+
  42. // | Author: Lorenzo Alberton <l.alberton@quipo.it>                       |
  43. // +----------------------------------------------------------------------+
  44. //
  45. // $Id: ibase.php,v 1.48 2006/05/14 05:51:45 lsmith Exp $
  46. //
  47.  
  48. require_once 'MDB2/Driver/Reverse/Common.php';
  49.  
  50. /**
  51.  * MDB2 InterbaseBase driver for the reverse engineering module
  52.  *
  53.  * @package MDB2
  54.  * @category Database
  55.  * @author Lorenzo Alberton  <l.alberton@quipo.it>
  56.  */
  57. class MDB2_Driver_Reverse_ibase extends MDB2_Driver_Reverse_Common
  58. {
  59.     /**
  60.      * Array for converting constant values to text values
  61.      * @var    array 
  62.      * @access public
  63.      */
  64.     var $types = array(
  65.         7   => 'smallint',
  66.         8   => 'integer',
  67.         9   => 'quad',
  68.         10  => 'float',
  69.         11  => 'd_float',
  70.         12  => 'date',      //dialect 3 DATE
  71.         13  => 'time',
  72.         14  => 'char',
  73.         16  => 'int64',
  74.         27  => 'double',
  75.         35  => 'timestamp'//DATE in older versions
  76.         37  => 'varchar',
  77.         40  => 'cstring',
  78.         261 => 'blob',
  79.     );
  80.  
  81.     /**
  82.      * Array for converting constant values to text values
  83.      * @var    array 
  84.      * @access public
  85.      */
  86.     var $subtypes = array(
  87.         //char subtypes
  88.         14 => array(
  89.             0 => 'unspecified',
  90.             1 => 'fixed'//BINARY data
  91.         ),
  92.         //blob subtypes
  93.         261 => array(
  94.             0 => 'unspecified',
  95.             1 => 'text',
  96.             2 => 'BLR'//Binary Language Representation
  97.             3 => 'access control list',
  98.             4 => 'reserved for future use',
  99.             5 => 'encoded description of a table\'s current metadata',
  100.             6 => 'description of multi-database transaction that finished irregularly',
  101.         ),
  102.         //smallint subtypes
  103.         7 => array(
  104.             0 => 'RDB$FIELD_TYPE',
  105.             1 => 'numeric',
  106.             2 => 'decimal',
  107.         ),
  108.         //integer subtypes
  109.         8 => array(
  110.             0 => 'RDB$FIELD_TYPE',
  111.             1 => 'numeric',
  112.             2 => 'decimal',
  113.         ),
  114.         //int64 subtypes
  115.         16 => array(
  116.             0 => 'RDB$FIELD_TYPE',
  117.             1 => 'numeric',
  118.             2 => 'decimal',
  119.         ),
  120.     );
  121.  
  122.     // {{{ getTableFieldDefinition()
  123.  
  124.     /**
  125.      * Get the stucture of a field into an array
  126.      *
  127.      * @param string    $table         name of table that should be used in method
  128.      * @param string    $field_name     name of field that should be used in method
  129.      * @return mixed data array on success, a MDB2 error on failure
  130.      * @access public
  131.      */
  132.     function getTableFieldDefinition($table$field_name)
  133.     {
  134.         $db =$this->getDBInstance();
  135.         if (PEAR::isError($db)) {
  136.             return $db;
  137.         }
  138.  
  139.         $result $db->loadModule('Datatype'nulltrue);
  140.         if (PEAR::isError($result)) {
  141.             return $result;
  142.         }
  143.         $table $db->quote(strtoupper($table)'text');
  144.         $field_name $db->quote(strtoupper($field_name)'text');
  145.         $query = "SELECT RDB\$RELATION_FIELDS.RDB\$FIELD_NAME AS name,
  146.                          RDB\$FIELDS.RDB\$FIELD_LENGTH AS \"length\",
  147.                          RDB\$FIELDS.RDB\$FIELD_TYPE AS field_type_code,
  148.                          RDB\$FIELDS.RDB\$FIELD_SUB_TYPE AS field_sub_type_code,
  149.                          RDB\$RELATION_FIELDS.RDB\$DESCRIPTION AS description,
  150.                          RDB\$RELATION_FIELDS.RDB\$NULL_FLAG AS null_flag,
  151.                          RDB\$FIELDS.RDB\$DEFAULT_SOURCE AS default_source
  152.                     FROM RDB\$FIELDS
  153.                LEFT JOIN RDB\$RELATION_FIELDS ON RDB\$FIELDS.RDB\$FIELD_NAME = RDB\$RELATION_FIELDS.RDB\$FIELD_SOURCE
  154.                    WHERE UPPER(RDB\$RELATION_FIELDS.RDB\$RELATION_NAME)=$table
  155.                      AND UPPER(RDB\$RELATION_FIELDS.RDB\$FIELD_NAME)=$field_name;";
  156.         $column $db->queryRow($querynullMDB2_FETCHMODE_ASSOC);
  157.         if (PEAR::isError($column)) {
  158.             return $column;
  159.         }
  160.         if (empty($column)) {
  161.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  162.                 'getTableFieldDefinition: it was not specified an existing table column');
  163.         }
  164.         $column array_change_key_case($columnCASE_LOWER);
  165.         if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  166.             if ($db->options['field_case'== CASE_LOWER{
  167.                 $column['name'strtolower($column['name']);
  168.             else {
  169.                 $column['name'strtoupper($column['name']);
  170.             }
  171.         }
  172.  
  173.         $column['type'array_key_exists($column['field_type_code']$this->types)
  174.             ? $this->types[(int)$column['field_type_code']] 'undefined';
  175.         if ($column['field_sub_type_code']
  176.             && array_key_exists($column['field_type_code']$this->subtypes)
  177.             && array_key_exists($column['field_sub_type_code']$this->subtypes[(int)$column['field_type_code']])
  178.         {
  179.             $column['field_sub_type'$this->subtypes[(int)$column['field_type_code']][$column['field_sub_type_code']];
  180.         else {
  181.             $column['field_sub_type'= null;
  182.         }
  183.         list($types$length$unsigned$fixed$db->datatype->mapNativeDatatype($column);
  184.         $notnull !empty($column['null_flag']);
  185.         $default $column['default_source'];
  186.         if (is_null($default&& $notnull{
  187.             $default ($types[0== 'integer'? 0 : '';
  188.         }
  189.         $definition = array();
  190.         foreach ($types as $key => $type{
  191.             $definition[$key= array(
  192.                 'type'    => $type,
  193.                 'notnull' => $notnull,
  194.             );
  195.             if ($length > 0{
  196.                 $definition[$key]['length'$length;
  197.             }
  198.             if (!is_null($unsigned)) {
  199.                 $definition[$key]['unsigned'$unsigned;
  200.             }
  201.             if (!is_null($fixed)) {
  202.                 $definition[$key]['fixed'$fixed;
  203.             }
  204.             $definition[$key]['default'$default;
  205.         }
  206.         return $definition;
  207.     }
  208.  
  209.     // }}}
  210.     // {{{ getTableIndexDefinition()
  211.  
  212.     /**
  213.      * Get the stucture of an index into an array
  214.      *
  215.      * @param string    $table      name of table that should be used in method
  216.      * @param string    $index_name name of index that should be used in method
  217.      * @return mixed data array on success, a MDB2 error on failure
  218.      * @access public
  219.      */
  220.     function getTableIndexDefinition($table$index_name)
  221.     {
  222.         $db =$this->getDBInstance();
  223.         if (PEAR::isError($db)) {
  224.             return $db;
  225.         }
  226.         $table $db->quote(strtoupper($table)'text');
  227.         $index_name $db->quote(strtoupper($db->getIndexName($index_name))'text');
  228.         $query = "SELECT RDB\$INDEX_SEGMENTS.RDB\$FIELD_NAME AS field_name,
  229.                          RDB\$INDICES.RDB\$UNIQUE_FLAG AS unique_flag,
  230.                          RDB\$INDICES.RDB\$FOREIGN_KEY AS foreign_key,
  231.                          RDB\$INDICES.RDB\$DESCRIPTION AS description
  232.                     FROM RDB\$INDEX_SEGMENTS
  233.                LEFT JOIN RDB\$INDICES ON RDB\$INDICES.RDB\$INDEX_NAME = RDB\$INDEX_SEGMENTS.RDB\$INDEX_NAME
  234.                LEFT JOIN RDB\$RELATION_CONSTRAINTS ON RDB\$RELATION_CONSTRAINTS.RDB\$INDEX_NAME = RDB\$INDEX_SEGMENTS.RDB\$INDEX_NAME
  235.                    WHERE UPPER(RDB\$INDICES.RDB\$RELATION_NAME)=$table
  236.                      AND UPPER(RDB\$INDICES.RDB\$INDEX_NAME)=$index_name
  237.                      AND RDB\$RELATION_CONSTRAINTS.RDB\$CONSTRAINT_TYPE IS NULL
  238.                 ORDER BY RDB\$INDEX_SEGMENTS.RDB\$FIELD_POSITION;";
  239.         $result $db->query($query);
  240.         if (PEAR::isError($result)) {
  241.             return $result;
  242.         }
  243.  
  244.         $index $row $result->fetchRow(MDB2_FETCHMODE_ASSOC);
  245.         if (empty($index)) {
  246.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  247.                 'getTableIndexDefinition: it was not specified an existing table index');
  248.         }
  249.  
  250.         $fields = array();
  251.         do {
  252.             $row array_change_key_case($rowCASE_LOWER);
  253.             $fields[$row['field_name'];
  254.         while (is_array($row $result->fetchRow(MDB2_FETCHMODE_ASSOC)));
  255.         $result->free();
  256.  
  257.         if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  258.             $fields array_map(($db->options['field_case'== CASE_LOWER ? 'strtolower' 'strtoupper')$fields);
  259.         }
  260.  
  261.         $definition = array();
  262.         foreach ($fields as $field{
  263.             $definition['fields'][$field= array();
  264.             //collation?!?
  265.             /*
  266.             if (array_key_exists('collation', $row)) {
  267.                 $definition['fields'][$field]['sorting'] = ($row['collation'] == 'A'
  268.                     ? 'ascending' : 'descending');
  269.             }
  270.             */
  271.         }
  272.         return $definition;
  273.     }
  274.  
  275.     // }}}
  276.     // {{{ getTableConstraintDefinition()
  277.  
  278.     /**
  279.      * Get the stucture of a constraint into an array
  280.      *
  281.      * @param string    $table      name of table that should be used in method
  282.      * @param string    $index_name name of index that should be used in method
  283.      * @return mixed data array on success, a MDB2 error on failure
  284.      * @access public
  285.      */
  286.     function getTableConstraintDefinition($table$index_name)
  287.     {
  288.         $db =$this->getDBInstance();
  289.         if (PEAR::isError($db)) {
  290.             return $db;
  291.         }
  292.         $table $db->quote(strtoupper($table)'text');
  293.         $index_name $db->quote(strtoupper($db->getIndexName($index_name))'text');
  294.         $query = "SELECT RDB\$INDEX_SEGMENTS.RDB\$FIELD_NAME AS field_name,
  295.                          RDB\$INDICES.RDB\$UNIQUE_FLAG AS unique_flag,
  296.                          RDB\$INDICES.RDB\$FOREIGN_KEY AS foreign_key,
  297.                          RDB\$INDICES.RDB\$DESCRIPTION AS description,
  298.                          RDB\$RELATION_CONSTRAINTS.RDB\$CONSTRAINT_TYPE AS constraint_type
  299.                     FROM RDB\$INDEX_SEGMENTS
  300.                LEFT JOIN RDB\$INDICES ON RDB\$INDICES.RDB\$INDEX_NAME = RDB\$INDEX_SEGMENTS.RDB\$INDEX_NAME
  301.                LEFT JOIN RDB\$RELATION_CONSTRAINTS ON RDB\$RELATION_CONSTRAINTS.RDB\$INDEX_NAME = RDB\$INDEX_SEGMENTS.RDB\$INDEX_NAME
  302.                    WHERE UPPER(RDB\$INDICES.RDB\$RELATION_NAME)=$table
  303.                      AND UPPER(RDB\$INDICES.RDB\$INDEX_NAME)=$index_name
  304.                 ORDER BY RDB\$INDEX_SEGMENTS.RDB\$FIELD_POSITION;";
  305.         $result $db->query($query);
  306.         if (PEAR::isError($result)) {
  307.             return $result;
  308.         }
  309.  
  310.         $index $row $result->fetchRow(MDB2_FETCHMODE_ASSOC);
  311.         if (empty($index)) {
  312.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  313.                 'getTableConstraintDefinition: it was not specified an existing table constraint');
  314.         }
  315.         $fields = array();
  316.         do {
  317.             $row array_change_key_case($rowCASE_LOWER);
  318.             $fields[$row['field_name'];
  319.         while (is_array($row $result->fetchRow(MDB2_FETCHMODE_ASSOC)));
  320.         $result->free();
  321.  
  322.         if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  323.             $fields array_map(($db->options['field_case'== CASE_LOWER ? 'strtolower' 'strtoupper')$fields);
  324.         }
  325.  
  326.         $definition = array();
  327.         if ($index['constraint_type'== 'PRIMARY KEY'{
  328.             $definition['primary'= true;
  329.         elseif ($index['unique_flag']{
  330.             $definition['unique'= true;
  331.         elseif ($index['foreign_key']{
  332.             $definition['foreign'= true;
  333.         }
  334.         if (!$index['unique_flag'&& !$index['foreign_key']{
  335.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  336.                 'getTableConstraintDefinition: it was not specified an existing table constraint');
  337.         }
  338.         foreach ($fields as $field{
  339.             $definition['fields'][$field= array();
  340.             //collation?!?
  341.             /*
  342.             if (array_key_exists('collation', $row)) {
  343.                 $definition['fields'][$field]['sorting'] = ($row['collation'] == 'A'
  344.                     ? 'ascending' : 'descending');
  345.             }
  346.             */
  347.         }
  348.         return $definition;
  349.     }
  350.  
  351.     // }}}
  352.     // {{{ getTriggerDefinition()
  353.  
  354.     /**
  355.      * Get the stucture of an trigger into an array
  356.      *
  357.      * @param string    $trigger    name of trigger that should be used in method
  358.      * @return mixed data array on success, a MDB2 error on failure
  359.      * @access public
  360.      */
  361.     function getTriggerDefinition($trigger)
  362.     {
  363.         $db =$this->getDBInstance();
  364.         if (PEAR::isError($db)) {
  365.             return $db;
  366.         }
  367.  
  368.         $trigger $db->quote(strtoupper($trigger)'text');
  369.         $query = "SELECT RDB\$TRIGGER_NAME AS trigger_name,
  370.                          RDB\$RELATION_NAME AS table_name,
  371.                          RDB\$TRIGGER_SOURCE AS trigger_body,
  372.                          RDB\$TRIGGER_TYPE AS trigger_type,
  373.                          RDB\$DESCRIPTION AS comment
  374.                     FROM RDB\$TRIGGERS
  375.                    WHERE UPPER(RDB\$TRIGGER_NAME)=$trigger";
  376.         return $db->queryRow();
  377.     }
  378.  
  379.     // }}}
  380.     // {{{ tableInfo()
  381.  
  382.     /**
  383.      * Returns information about a table or a result set
  384.      *
  385.      * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  386.      * is a table name.
  387.      *
  388.      * @param object|string $result  MDB2_result object from a query or a
  389.      *                                  string containing the name of a table.
  390.      *                                  While this also accepts a query result
  391.      *                                  resource identifier, this behavior is
  392.      *                                  deprecated.
  393.      * @param int            $mode    a valid tableInfo mode
  394.      *
  395.      * @return array  an associative array with the information requested.
  396.      *                  A MDB2_Error object on failure.
  397.      *
  398.      * @see MDB2_Driver_Common::tableInfo()
  399.      */
  400.     function tableInfo($result$mode = null)
  401.     {
  402.         $db =$this->getDBInstance();
  403.         if (PEAR::isError($db)) {
  404.             return $db;
  405.         }
  406.  
  407.         if (is_string($result)) {
  408.             /*
  409.              * Probably received a table name.
  410.              * Create a result resource identifier.
  411.              */
  412.             $id =$db->_doQuery('SELECT * FROM '.$db->quoteIdentifier($result).' WHERE 1=0'false);
  413.             if (PEAR::isError($id)) {
  414.                 return $id;
  415.             }
  416.             $got_string = true;
  417.         elseif (MDB2::isResultCommon($result)) {
  418.             /*
  419.              * Probably received a result object.
  420.              * Extract the result resource identifier.
  421.              */
  422.             $id $result->getResource();
  423.             $got_string = false;
  424.         else {
  425.             /*
  426.              * Probably received a result resource identifier.
  427.              * Copy it.
  428.              * Deprecated.  Here for compatibility only.
  429.              */
  430.             $id $result;
  431.             $got_string = false;
  432.         }
  433.  
  434.         if (!is_resource($id)) {
  435.             return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
  436.         }
  437.  
  438.         if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  439.             if ($db->options['field_case'== CASE_LOWER{
  440.                 $case_func 'strtolower';
  441.             else {
  442.                 $case_func 'strtoupper';
  443.             }
  444.         else {
  445.             $case_func 'strval';
  446.         }
  447.  
  448.         $count @ibase_num_fields($id);
  449.         $res   = array();
  450.  
  451.         if ($mode{
  452.             $res['num_fields'$count;
  453.         }
  454.  
  455.         $db->loadModule('Datatype'nulltrue);
  456.         for ($i = 0; $i $count$i++{
  457.             $info @ibase_field_info($id$i);
  458.             if (($pos strpos($info['type']'(')) !== false{
  459.                 $info['type'substr($info['type']0$pos);
  460.             }
  461.             $res[$i= array(
  462.                 'table'  => $got_string $case_func($result'',
  463.                 'name'   => $case_func($info['name']),
  464.                 'type'   => $info['type'],
  465.                 'length' => $info['length'],
  466.                 'flags'  => ($got_string)
  467.                             ? $this->_ibaseFieldFlags($info['name']$result'',
  468.             );
  469.             $mdb2type_info $db->datatype->mapNativeDatatype($res[$i]);
  470.             if (PEAR::isError($mdb2type_info)) {
  471.                return $mdb2type_info;
  472.             }
  473.             $res[$i]['mdb2type'$mdb2type_info[0][0];
  474.             if ($mode MDB2_TABLEINFO_ORDER{
  475.                 $res['order'][$res[$i]['name']] $i;
  476.             }
  477.             if ($mode MDB2_TABLEINFO_ORDERTABLE{
  478.                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] $i;
  479.             }
  480.         }
  481.  
  482.         // free the result only if we were called on a table
  483.         if ($got_string{
  484.             @ibase_free_result($id);
  485.         }
  486.         return $res;
  487.     }
  488.  
  489.     // }}}
  490.     // {{{ _ibaseFieldFlags()
  491.  
  492.     /**
  493.      * Get the column's flags
  494.      *
  495.      * Supports "primary_key", "unique_key", "not_null", "default",
  496.      * "computed" and "blob".
  497.      *
  498.      * @param string $field_name  the name of the field
  499.      * @param string $table_name  the name of the table
  500.      *
  501.      * @return string  the flags
  502.      *
  503.      * @access protected
  504.      */
  505.     function _ibaseFieldFlags($field_name$table_name)
  506.     {
  507.         $db =$this->getDBInstance();
  508.         if (PEAR::isError($db)) {
  509.             return $db;
  510.         }
  511.  
  512.         $query 'SELECT R.RDB$CONSTRAINT_TYPE CTYPE'
  513.                .' FROM RDB$INDEX_SEGMENTS I'
  514.                .'  JOIN RDB$RELATION_CONSTRAINTS R ON I.RDB$INDEX_NAME=R.RDB$INDEX_NAME'
  515.                .' WHERE I.RDB$FIELD_NAME=\'' $field_name '\''
  516.                .'  AND UPPER(R.RDB$RELATION_NAME)=\'' strtoupper($table_name'\'';
  517.  
  518.         $result =$db->_doQuery($queryfalse);
  519.         if (PEAR::isError($result)) {
  520.             return $result;
  521.         }
  522.  
  523.         $flags '';
  524.         if ($obj @ibase_fetch_object($result)) {
  525.             @ibase_free_result($result);
  526.             if (isset($obj->CTYPE)  && trim($obj->CTYPE== 'PRIMARY KEY'{
  527.                 $flags.= 'primary_key ';
  528.             }
  529.             if (isset($obj->CTYPE)  && trim($obj->CTYPE== 'UNIQUE'{
  530.                 $flags.= 'unique_key ';
  531.             }
  532.         }
  533.  
  534.         $query 'SELECT R.RDB$NULL_FLAG AS NFLAG,'
  535.                .'  R.RDB$DEFAULT_SOURCE AS DSOURCE,'
  536.                .'  F.RDB$FIELD_TYPE AS FTYPE,'
  537.                .'  F.RDB$COMPUTED_SOURCE AS CSOURCE'
  538.                .' FROM RDB$RELATION_FIELDS R '
  539.                .'  JOIN RDB$FIELDS F ON R.RDB$FIELD_SOURCE=F.RDB$FIELD_NAME'
  540.                .' WHERE UPPER(R.RDB$RELATION_NAME)=\'' strtoupper($table_name'\''
  541.                .'  AND R.RDB$FIELD_NAME=\'' $field_name '\'';
  542.  
  543.         $result =$db->_doQuery($queryfalse);
  544.         if (PEAR::isError($result)) {
  545.             return $result;
  546.         }
  547.  
  548.         if ($obj @ibase_fetch_object($result)) {
  549.             @ibase_free_result($result);
  550.             if (isset($obj->NFLAG)) {
  551.                 $flags.= 'not_null ';
  552.             }
  553.             if (isset($obj->DSOURCE)) {
  554.                 $flags.= 'default ';
  555.             }
  556.             if (isset($obj->CSOURCE)) {
  557.                 $flags.= 'computed ';
  558.             }
  559.             if (isset($obj->FTYPE)  && $obj->FTYPE == 261{
  560.                 $flags.= 'blob ';
  561.             }
  562.         }
  563.  
  564.         return trim($flags);
  565.     }
  566. }
  567. ?>

Documentation generated on Mon, 11 Mar 2019 14:39:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.