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

Source for file oci8.php

Documentation is available at oci8.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5                                                 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2007 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. // | Authors: Lukas Smith <smith@pooteeweet.org>                          |
  43. // |          Lorenzo Alberton <l.alberton@quipo.it>                      |
  44. // +----------------------------------------------------------------------+
  45. //
  46. // $Id: oci8.php 327310 2012-08-27 15:16:18Z danielc $
  47. //
  48.  
  49. require_once 'MDB2/Driver/Reverse/Common.php';
  50.  
  51. /**
  52.  * MDB2 Oracle driver for the schema reverse engineering module
  53.  *
  54.  * @package MDB2
  55.  * @category Database
  56.  * @author  Lukas Smith <smith@dybnet.de>
  57.  */
  58. class MDB2_Driver_Reverse_oci8 extends MDB2_Driver_Reverse_Common
  59. {
  60.     // {{{ getTableFieldDefinition()
  61.  
  62.     /**
  63.      * Get the structure of a field into an array
  64.      *
  65.      * @param string $table_name name of table that should be used in method
  66.      * @param string $field_name name of field that should be used in method
  67.      * @return mixed data array on success, a MDB2 error on failure
  68.      * @access public
  69.      */
  70.     function getTableFieldDefinition($table_name$field_name)
  71.     {
  72.         $db $this->getDBInstance();
  73.         if (MDB2::isError($db)) {
  74.             return $db;
  75.         }
  76.  
  77.         $result $db->loadModule('Datatype'nulltrue);
  78.         if (MDB2::isError($result)) {
  79.             return $result;
  80.         }
  81.  
  82.         list($owner$table$this->splitTableSchema($table_name);
  83.         if (empty($owner)) {
  84.             $owner $db->dsn['username'];
  85.         }
  86.  
  87.         $query 'SELECT column_name name,
  88.                          data_type "type",
  89.                          nullable,
  90.                          data_default "default",
  91.                          COALESCE(data_precision, data_length) "length",
  92.                          data_scale "scale"
  93.                     FROM all_tab_columns
  94.                    WHERE (table_name=? OR table_name=?)
  95.                      AND (owner=? OR owner=?)
  96.                      AND (column_name=? OR column_name=?)
  97.                 ORDER BY column_id';
  98.         $stmt $db->prepare($query);
  99.         if (MDB2::isError($stmt)) {
  100.             return $stmt;
  101.         }
  102.         $args = array(
  103.             $table,
  104.             strtoupper($table),
  105.             $owner,
  106.             strtoupper($owner),
  107.             $field_name,
  108.             strtoupper($field_name)
  109.         );
  110.         $result $stmt->execute($args);
  111.         if (MDB2::isError($result)) {
  112.             return $result;
  113.         }
  114.         $column $result->fetchRow(MDB2_FETCHMODE_ASSOC);
  115.         if (MDB2::isError($column)) {
  116.             return $column;
  117.         }
  118.         $stmt->free();
  119.         $result->free();
  120.  
  121.         if (empty($column)) {
  122.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  123.                 $field_name ' is not a column in table ' $table_name__FUNCTION__);
  124.         }
  125.  
  126.         $column array_change_key_case($columnCASE_LOWER);
  127.         if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  128.             if ($db->options['field_case'== CASE_LOWER{
  129.                 $column['name'strtolower($column['name']);
  130.             else {
  131.                 $column['name'strtoupper($column['name']);
  132.             }
  133.         }
  134.         $mapped_datatype $db->datatype->mapNativeDatatype($column);
  135.         if (MDB2::isError($mapped_datatype)) {
  136.             return $mapped_datatype;
  137.         }
  138.         list($types$length$unsigned$fixed$mapped_datatype;
  139.         $notnull = false;
  140.         if (!empty($column['nullable']&& $column['nullable'== 'N'{
  141.             $notnull = true;
  142.         }
  143.         $default = false;
  144.         if (array_key_exists('default'$column)) {
  145.             $default $column['default'];
  146.             if ($default === 'NULL'{
  147.                 $default = null;
  148.             }
  149.             if ((null === $default&& $notnull{
  150.                 $default '';
  151.             }
  152.         }
  153.  
  154.         $definition[0= array('notnull' => $notnull'nativetype' => $column['type']);
  155.         if (null !== $length{
  156.             $definition[0]['length'$length;
  157.         }
  158.         if (null !== $unsigned{
  159.             $definition[0]['unsigned'$unsigned;
  160.         }
  161.         if (null !== $fixed{
  162.             $definition[0]['fixed'$fixed;
  163.         }
  164.         if ($default !== false{
  165.             $definition[0]['default'$default;
  166.         }
  167.         foreach ($types as $key => $type{
  168.             $definition[$key$definition[0];
  169.             if ($type == 'clob' || $type == 'blob'{
  170.                 unset($definition[$key]['default']);
  171.             }
  172.             $definition[$key]['type'$type;
  173.             $definition[$key]['mdb2type'$type;
  174.         }
  175.         if ($type == 'integer'{
  176.             $query"SELECT trigger_body
  177.                        FROM all_triggers
  178.                       WHERE table_name=?
  179.                         AND triggering_event='INSERT'
  180.                         AND trigger_type='BEFORE EACH ROW'";
  181.             // ^^ pretty reasonable mimic for "auto_increment" in oracle?
  182.             $stmt $db->prepare($query);
  183.             if (MDB2::isError($stmt)) {
  184.                 return $stmt;
  185.             }
  186.             $result $stmt->execute(strtoupper($table));
  187.             if (MDB2::isError($result)) {
  188.                 return $result;
  189.             }
  190.             while ($triggerstr $result->fetchOne()) {
  191.                    if (preg_match('/.*SELECT\W+(.+)\.nextval +into +\:NEW\.'.$field_name.' +FROM +dual/im'$triggerstr$matches)) {
  192.                     $definition[0]['autoincrement'$matches[1];
  193.                 }
  194.             }
  195.             $stmt->free();
  196.             $result->free();
  197.         }
  198.         return $definition;
  199.     }
  200.  
  201.     // }}}
  202.     // {{{ getTableIndexDefinition()
  203.  
  204.     /**
  205.      * Get the structure of an index into an array
  206.      *
  207.      * @param string $table_name name of table that should be used in method
  208.      * @param string $index_name name of index that should be used in method
  209.      * @return mixed data array on success, a MDB2 error on failure
  210.      * @access public
  211.      */
  212.     function getTableIndexDefinition($table_name$index_name)
  213.     {
  214.         $db $this->getDBInstance();
  215.         if (MDB2::isError($db)) {
  216.             return $db;
  217.         }
  218.         
  219.         list($owner$table$this->splitTableSchema($table_name);
  220.         if (empty($owner)) {
  221.             $owner $db->dsn['username'];
  222.         }
  223.  
  224.         $query "SELECT aic.column_name,
  225.                          aic.column_position,
  226.                          aic.descend,
  227.                          aic.table_owner,
  228.                          alc.constraint_type
  229.                     FROM all_ind_columns aic
  230.                LEFT JOIN all_constraints alc
  231.                       ON aic.index_name = alc.constraint_name
  232.                      AND aic.table_name = alc.table_name
  233.                      AND aic.table_owner = alc.owner
  234.                    WHERE (aic.table_name=? OR aic.table_name=?)
  235.                      AND (aic.index_name=? OR aic.index_name=?)
  236.                      AND (aic.table_owner=? OR aic.table_owner=?)
  237.                 ORDER BY column_position";
  238.         $stmt $db->prepare($query);
  239.         if (MDB2::isError($stmt)) {
  240.             return $stmt;
  241.         }
  242.         $indexnames array_unique(array($db->getIndexName($index_name)$index_name));
  243.         $i = 0;
  244.         $row = null;
  245.         while ((null === $row&& array_key_exists($i$indexnames)) {
  246.             $args = array(
  247.                 $table,
  248.                 strtoupper($table),
  249.                 $indexnames[$i],
  250.                 strtoupper($indexnames[$i]),
  251.                 $owner,
  252.                 strtoupper($owner)
  253.             );
  254.             $result $stmt->execute($args);
  255.             if (MDB2::isError($result)) {
  256.                 return $result;
  257.             }
  258.             $row $result->fetchRow(MDB2_FETCHMODE_ASSOC);
  259.             if (MDB2::isError($row)) {
  260.                 return $row;
  261.             }
  262.             $i++;
  263.         }
  264.         if (null === $row{
  265.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  266.                 $index_name' is not an index on table '$table_name__FUNCTION__);
  267.         }
  268.         if ($row['constraint_type'== 'U' || $row['constraint_type'== 'P'{
  269.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  270.                 $index_name' is a constraint, not an index on table '$table_name__FUNCTION__);
  271.         }
  272.  
  273.         $definition = array();
  274.         while (null !== $row{
  275.             $row array_change_key_case($rowCASE_LOWER);
  276.             $column_name $row['column_name'];
  277.             if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  278.                 if ($db->options['field_case'== CASE_LOWER{
  279.                     $column_name strtolower($column_name);
  280.                 else {
  281.                     $column_name strtoupper($column_name);
  282.                 }
  283.             }
  284.             $definition['fields'][$column_name= array(
  285.                 'position' => (int)$row['column_position'],
  286.             );
  287.             if (!empty($row['descend'])) {
  288.                 $definition['fields'][$column_name]['sorting'=
  289.                     ($row['descend'== 'ASC' 'ascending' 'descending');
  290.             }
  291.             $row $result->fetchRow(MDB2_FETCHMODE_ASSOC);
  292.         }
  293.         $result->free();
  294.         if (empty($definition['fields'])) {
  295.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  296.                 $index_name' is not an index on table '$table_name__FUNCTION__);
  297.         }
  298.         return $definition;
  299.     }
  300.  
  301.     // }}}
  302.     // {{{ getTableConstraintDefinition()
  303.  
  304.     /**
  305.      * Get the structure of a constraint into an array
  306.      *
  307.      * @param string $table_name      name of table that should be used in method
  308.      * @param string $constraint_name name of constraint that should be used in method
  309.      * @return mixed data array on success, a MDB2 error on failure
  310.      * @access public
  311.      */
  312.     function getTableConstraintDefinition($table_name$constraint_name)
  313.     {
  314.         $db $this->getDBInstance();
  315.         if (MDB2::isError($db)) {
  316.             return $db;
  317.         }
  318.         
  319.         list($owner$table$this->splitTableSchema($table_name);
  320.         if (empty($owner)) {
  321.             $owner $db->dsn['username'];
  322.         }
  323.         
  324.         $query 'SELECT alc.constraint_name,
  325.                          CASE alc.constraint_type WHEN \'P\' THEN 1 ELSE 0 END "primary",
  326.                          CASE alc.constraint_type WHEN \'R\' THEN 1 ELSE 0 END "foreign",
  327.                          CASE alc.constraint_type WHEN \'U\' THEN 1 ELSE 0 END "unique",
  328.                          CASE alc.constraint_type WHEN \'C\' THEN 1 ELSE 0 END "check",
  329.                          alc.DELETE_RULE "ondelete",
  330.                          \'NO ACTION\' "onupdate",
  331.                          \'SIMPLE\' "match",
  332.                          CASE alc.deferrable WHEN \'NOT DEFERRABLE\' THEN 0 ELSE 1 END "deferrable",
  333.                          CASE alc.deferred WHEN \'IMMEDIATE\' THEN 0 ELSE 1 END "initiallydeferred",
  334.                          alc.search_condition,
  335.                          alc.table_name,
  336.                          cols.column_name,
  337.                          cols.position,
  338.                          r_alc.table_name "references_table",
  339.                          r_cols.column_name "references_field",
  340.                          r_cols.position "references_field_position"
  341.                     FROM all_cons_columns cols
  342.                LEFT JOIN all_constraints alc
  343.                       ON alc.constraint_name = cols.constraint_name
  344.                      AND alc.owner = cols.owner
  345.                LEFT JOIN all_constraints r_alc
  346.                       ON alc.r_constraint_name = r_alc.constraint_name
  347.                      AND alc.r_owner = r_alc.owner
  348.                LEFT JOIN all_cons_columns r_cols
  349.                       ON r_alc.constraint_name = r_cols.constraint_name
  350.                      AND r_alc.owner = r_cols.owner
  351.                      AND cols.position = r_cols.position
  352.                    WHERE (alc.constraint_name=? OR alc.constraint_name=?)
  353.                      AND alc.constraint_name = cols.constraint_name
  354.                      AND (alc.owner=? OR alc.owner=?)';
  355.         $tablenames = array();
  356.         if (!empty($table)) {
  357.             $query.= ' AND (alc.table_name=? OR alc.table_name=?)';
  358.             $tablenames = array($tablestrtoupper($table));
  359.         }
  360.         $stmt $db->prepare($query);
  361.         if (MDB2::isError($stmt)) {
  362.             return $stmt;
  363.         }
  364.         
  365.         $constraintnames array_unique(array($db->getIndexName($constraint_name)$constraint_name));
  366.         $c = 0;
  367.         $row = null;
  368.         while ((null === $row&& array_key_exists($c$constraintnames)) {
  369.             $args = array(
  370.                 $constraintnames[$c],
  371.                 strtoupper($constraintnames[$c]),
  372.                 $owner,
  373.                 strtoupper($owner)
  374.             );
  375.             if (!empty($table)) {
  376.                 $args array_merge($args$tablenames);
  377.             }
  378.             $result $stmt->execute($args);
  379.             if (MDB2::isError($result)) {
  380.                 return $result;
  381.             }
  382.             $row $result->fetchRow(MDB2_FETCHMODE_ASSOC);
  383.             if (MDB2::isError($row)) {
  384.                 return $row;
  385.             }
  386.             $c++;
  387.         }
  388.  
  389.         $definition = array(
  390.             'primary' => (boolean)$row['primary'],
  391.             'unique'  => (boolean)$row['unique'],
  392.             'foreign' => (boolean)$row['foreign'],
  393.             'check'   => (boolean)$row['check'],
  394.             'deferrable' => (boolean)$row['deferrable'],
  395.             'initiallydeferred' => (boolean)$row['initiallydeferred'],
  396.             'ondelete' => $row['ondelete'],
  397.             'onupdate' => $row['onupdate'],
  398.             'match'    => $row['match'],
  399.         );
  400.  
  401.         if ($definition['check']{
  402.             // pattern match constraint for check constraint values into enum-style output:
  403.             $enumregex '/'.$row['column_name'].' in \((.+?)\)/i';
  404.             if (preg_match($enumregex$row['search_condition']$rangestr)) {
  405.                 $definition['fields'][$column_name= array();
  406.                 $allowed explode(','$rangestr[1]);
  407.                 foreach ($allowed as $val{
  408.                     $val trim($val);
  409.                     $val preg_replace('/^\'/'''$val);
  410.                     $val preg_replace('/\'$/'''$val);
  411.                     array_push($definition['fields'][$column_name]$val);
  412.                 }
  413.             }
  414.         }
  415.         
  416.         while (null !== $row{
  417.             $row array_change_key_case($rowCASE_LOWER);
  418.             $column_name $row['column_name'];
  419.             if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  420.                 if ($db->options['field_case'== CASE_LOWER{
  421.                     $column_name strtolower($column_name);
  422.                 else {
  423.                     $column_name strtoupper($column_name);
  424.                 }
  425.             }
  426.             $definition['fields'][$column_name= array(
  427.                 'position' => (int)$row['position']
  428.             );
  429.             if ($row['foreign']{
  430.                 $ref_column_name $row['references_field'];
  431.                 $ref_table_name  $row['references_table'];
  432.                 if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  433.                     if ($db->options['field_case'== CASE_LOWER{
  434.                         $ref_column_name strtolower($ref_column_name);
  435.                         $ref_table_name  strtolower($ref_table_name);
  436.                     else {
  437.                         $ref_column_name strtoupper($ref_column_name);
  438.                         $ref_table_name  strtoupper($ref_table_name);
  439.                     }
  440.                 }
  441.                 $definition['references']['table'$ref_table_name;
  442.                 $definition['references']['fields'][$ref_column_name= array(
  443.                     'position' => (int)$row['references_field_position']
  444.                 );
  445.             }
  446.             $lastrow $row;
  447.             $row $result->fetchRow(MDB2_FETCHMODE_ASSOC);
  448.         }
  449.         $result->free();
  450.         if (empty($definition['fields'])) {
  451.             return $db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  452.                 $constraint_name ' is not a constraint on table '$table_name__FUNCTION__);
  453.         }
  454.  
  455.         return $definition;
  456.     }
  457.  
  458.     // }}}
  459.     // {{{ getSequenceDefinition()
  460.  
  461.     /**
  462.      * Get the structure of a sequence into an array
  463.      *
  464.      * @param string    $sequence   name of sequence that should be used in method
  465.      * @return mixed data array on success, a MDB2 error on failure
  466.      * @access public
  467.      */
  468.     function getSequenceDefinition($sequence)
  469.     {
  470.         $db $this->getDBInstance();
  471.         if (MDB2::isError($db)) {
  472.             return $db;
  473.         }
  474.  
  475.         $sequence_name $db->getSequenceName($sequence);
  476.         $query 'SELECT last_number FROM user_sequences';
  477.         $query.= ' WHERE sequence_name='.$db->quote($sequence_name'text');
  478.         $query.= '    OR sequence_name='.$db->quote(strtoupper($sequence_name)'text');
  479.         $start $db->queryOne($query'integer');
  480.         if (MDB2::isError($start)) {
  481.             return $start;
  482.         }
  483.         $definition = array();
  484.         if ($start != 1{
  485.             $definition = array('start' => $start);
  486.         }
  487.         return $definition;
  488.     }
  489.  
  490.     // }}}
  491.     // {{{ getTriggerDefinition()
  492.  
  493.     /**
  494.      * Get the structure of a trigger into an array
  495.      *
  496.      * EXPERIMENTAL
  497.      *
  498.      * WARNING: this function is experimental and may change the returned value
  499.      * at any time until labelled as non-experimental
  500.      *
  501.      * @param string    $trigger    name of trigger that should be used in method
  502.      * @return mixed data array on success, a MDB2 error on failure
  503.      * @access public
  504.      */
  505.     function getTriggerDefinition($trigger)
  506.     {
  507.         $db $this->getDBInstance();
  508.         if (MDB2::isError($db)) {
  509.             return $db;
  510.         }
  511.  
  512.         $query 'SELECT trigger_name,
  513.                          table_name,
  514.                          trigger_body,
  515.                          trigger_type,
  516.                          triggering_event trigger_event,
  517.                          description trigger_comment,
  518.                          1 trigger_enabled,
  519.                          when_clause
  520.                     FROM user_triggers
  521.                    WHERE trigger_name = \''strtoupper($trigger).'\'';
  522.         $types = array(
  523.             'trigger_name'    => 'text',
  524.             'table_name'      => 'text',
  525.             'trigger_body'    => 'text',
  526.             'trigger_type'    => 'text',
  527.             'trigger_event'   => 'text',
  528.             'trigger_comment' => 'text',
  529.             'trigger_enabled' => 'boolean',
  530.             'when_clause'     => 'text',
  531.         );
  532.         $result $db->queryRow($query$typesMDB2_FETCHMODE_ASSOC);
  533.         if (MDB2::isError($result)) {
  534.             return $result;
  535.         }
  536.         if (!empty($result['trigger_type'])) {
  537.             //$result['trigger_type'] = array_shift(explode(' ', $result['trigger_type']));
  538.             $result['trigger_type'preg_replace('/(\S+).*/''\\1'$result['trigger_type']);
  539.         }
  540.         return $result;
  541.     }
  542.  
  543.     // }}}
  544.     // {{{ tableInfo()
  545.  
  546.     /**
  547.      * Returns information about a table or a result set
  548.      *
  549.      * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  550.      * is a table name.
  551.      *
  552.      * NOTE: flags won't contain index information.
  553.      *
  554.      * @param object|string $result  MDB2_result object from a query or a
  555.      *                                  string containing the name of a table.
  556.      *                                  While this also accepts a query result
  557.      *                                  resource identifier, this behavior is
  558.      *                                  deprecated.
  559.      * @param int            $mode    a valid tableInfo mode
  560.      *
  561.      * @return array  an associative array with the information requested.
  562.      *                  A MDB2_Error object on failure.
  563.      *
  564.      * @see MDB2_Driver_Common::tableInfo()
  565.      */
  566.     function tableInfo($result$mode = null)
  567.     {
  568.         if (is_string($result)) {
  569.            return parent::tableInfo($result$mode);
  570.         }
  571.  
  572.         $db $this->getDBInstance();
  573.         if (MDB2::isError($db)) {
  574.             return $db;
  575.         }
  576.  
  577.         $resource = MDB2::isResultCommon($result$result->getResource($result;
  578.         if (!is_resource($resource)) {
  579.             return $db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  580.                 'Could not generate result resource'__FUNCTION__);
  581.         }
  582.  
  583.         if ($db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  584.             if ($db->options['field_case'== CASE_LOWER{
  585.                 $case_func 'strtolower';
  586.             else {
  587.                 $case_func 'strtoupper';
  588.             }
  589.         else {
  590.             $case_func 'strval';
  591.         }
  592.  
  593.         $count @OCINumCols($resource);
  594.         $res = array();
  595.  
  596.         if ($mode{
  597.             $res['num_fields'$count;
  598.         }
  599.  
  600.         $db->loadModule('Datatype'nulltrue);
  601.         for ($i = 0; $i $count$i++{
  602.             $column = array(
  603.                 'table'  => '',
  604.                 'name'   => $case_func(@OCIColumnName($resource$i+1)),
  605.                 'type'   => @OCIColumnType($resource$i+1),
  606.                 'length' => @OCIColumnSize($resource$i+1),
  607.                 'flags'  => '',
  608.             );
  609.             $res[$i$column;
  610.             $res[$i]['mdb2type'$db->datatype->mapNativeDatatype($res[$i]);
  611.             if ($mode MDB2_TABLEINFO_ORDER{
  612.                 $res['order'][$res[$i]['name']] $i;
  613.             }
  614.             if ($mode MDB2_TABLEINFO_ORDERTABLE{
  615.                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] $i;
  616.             }
  617.         }
  618.         return $res;
  619.     }
  620. }
  621. ?>

Documentation generated on Mon, 11 Mar 2019 15:51:20 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.