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

Source for file oci8.php

Documentation is available at oci8.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP Version 4                                                        |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |
  6. // | Stig. S. Bakken, Lukas Smith, Frank M. Kromann                       |
  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: Lukas Smith <smith@backendmedia.com>                         |
  43. // +----------------------------------------------------------------------+
  44. //
  45. // $Id: oci8.php,v 1.7 2004/03/10 14:12:12 lsmith Exp $
  46. //
  47.  
  48. require_once 'MDB2/Driver/Reverse/Common.php';
  49.  
  50. /**
  51.  * MDB2 Oracle driver for the schema reverse engineering module
  52.  *
  53.  * @package MDB2
  54.  * @category Database
  55.  * @author  Lukas Smith <smith@dybnet.de>
  56.  */
  57. {
  58.     // }}}
  59.     // {{{ constructor
  60.  
  61.     /**
  62.      * Constructor
  63.      */
  64.     function MDB2_Driver_Reverse_oci8($db_index)
  65.     {
  66.         $this->MDB2_Driver_Reverse_Common($db_index);
  67.     }
  68.  
  69.     // }}}
  70.     // {{{ tableInfo()
  71.  
  72.     /**
  73.      * Returns information about a table or a result set.
  74.      *
  75.      * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  76.      * is a table name.
  77.      *
  78.      * NOTE: flags won't contain index information.
  79.      *
  80.      * @param object|string $result  MDB2_result object from a query or a
  81.      *                                 string containing the name of a table
  82.      * @param int            $mode    a valid tableInfo mode
  83.      * @return array  an associative array with the information requested
  84.      *                 or an error object if something is wrong
  85.      * @access public
  86.      * @internal
  87.      * @see MDB2_Driver_Common::tableInfo()
  88.      */
  89.     function tableInfo($result$mode = null)
  90.     {
  91.         $db =$GLOBALS['_MDB2_databases'][$this->db_index];
  92.         if ($db->options['portability'MDB2_PORTABILITY_LOWERCASE{
  93.             $case_func 'strtolower';
  94.         else {
  95.             $case_func 'strval';
  96.         }
  97.  
  98.         if (is_string($result)) {
  99.             /*
  100.              * Probably received a table name.
  101.              * Create a result resource identifier.
  102.              */
  103.             if (MDB2::isError($connect $db->connect())) {
  104.                 return $connect;
  105.             }
  106.             $result strtoupper($result);
  107.             $q_fields 'SELECT column_name, data_type, data_length, '
  108.                         . 'nullable '
  109.                         . 'FROM user_tab_columns '
  110.                         . "WHERE table_name='$result' ORDER BY column_id";
  111.  
  112.             $db->last_query = $q_fields;
  113.  
  114.             if (!$stmt @OCIParse($db->connection$q_fields)) {
  115.                 return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
  116.             }
  117.             if (!@OCIExecute($stmtOCI_DEFAULT)) {
  118.                 return $db->raiseError($stmt);
  119.             }
  120.  
  121.             $i = 0;
  122.             while (@OCIFetch($stmt)) {
  123.                 $res[$i]['table'$case_func($result);
  124.                 $res[$i]['name']  $case_func(@OCIResult($stmt1));
  125.                 $res[$i]['type']  @OCIResult($stmt2);
  126.                 $res[$i]['len']   @OCIResult($stmt3);
  127.                 $res[$i]['flags'(@OCIResult($stmt4== 'N''not_null' '';
  128.  
  129.                 if ($mode MDB2_TABLEINFO_ORDER{
  130.                     $res['order'][$res[$i]['name']] $i;
  131.                 }
  132.                 if ($mode MDB2_TABLEINFO_ORDERTABLE{
  133.                     $res['ordertable'][$res[$i]['table']][$res[$i]['name']] $i;
  134.                 }
  135.                 $i++;
  136.             }
  137.  
  138.             if ($mode{
  139.                 $res['num_fields'$i;
  140.             }
  141.             @OCIFreeStatement($stmt);
  142.  
  143.         else {
  144.             /*
  145.              * Probably received a result object.
  146.              * Extract the result resource identifier.
  147.              */
  148.             $id $result->getResource();
  149.             if (empty($id)) {
  150.                 return $db->raiseError();
  151.             }
  152.  
  153. #            if ($result === $db->last_stmt) {
  154.                 $count @OCINumCols($id);
  155.  
  156.                 for ($i=0; $i<$count$i++{
  157.                     $res[$i]['table''';
  158.                     $res[$i]['name']  $case_func(@OCIColumnName($id$i+1));
  159.                     $res[$i]['type']  @OCIColumnType($id$i+1);
  160.                     $res[$i]['len']   @OCIColumnSize($id$i+1);
  161.                     $res[$i]['flags''';
  162.  
  163.                     if ($mode MDB2_TABLEINFO_ORDER{
  164.                         $res['order'][$res[$i]['name']] $i;
  165.                     }
  166.                     if ($mode MDB2_TABLEINFO_ORDERTABLE{
  167.                         $res['ordertable'][$res[$i]['table']][$res[$i]['name']] $i;
  168.                     }
  169.                 }
  170.  
  171.                 if ($mode{
  172.                     $res['num_fields'$i;
  173.                 }
  174.  
  175. #            } else {
  176. #                return $db->raiseError(MDB2_ERROR_NOT_CAPABLE);
  177. #            }
  178.         }
  179.         return $res;
  180.     }
  181. }
  182. ?>

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