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

Source for file oci8.php

Documentation is available at oci8.php

  1. <?php
  2. // vim: set et ts=4 sw=4 fdm=marker:
  3. // +----------------------------------------------------------------------+
  4. // | PHP versions 4 and 5                                                 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox,                 |
  7. // | Stig. S. Bakken, Lukas Smith                                         |
  8. // | All rights reserved.                                                 |
  9. // +----------------------------------------------------------------------+
  10. // | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB  |
  11. // | API as well as database abstraction for PHP applications.            |
  12. // | This LICENSE is in the BSD license style.                            |
  13. // |                                                                      |
  14. // | Redistribution and use in source and binary forms, with or without   |
  15. // | modification, are permitted provided that the following conditions   |
  16. // | are met:                                                             |
  17. // |                                                                      |
  18. // | Redistributions of source code must retain the above copyright       |
  19. // | notice, this list of conditions and the following disclaimer.        |
  20. // |                                                                      |
  21. // | Redistributions in binary form must reproduce the above copyright    |
  22. // | notice, this list of conditions and the following disclaimer in the  |
  23. // | documentation and/or other materials provided with the distribution. |
  24. // |                                                                      |
  25. // | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
  26. // | Lukas Smith nor the names of his contributors may be used to endorse |
  27. // | or promote products derived from this software without specific prior|
  28. // | written permission.                                                  |
  29. // |                                                                      |
  30. // | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
  31. // | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
  32. // | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
  33. // | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
  34. // | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
  35. // | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
  36. // | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
  37. // |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
  38. // | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
  39. // | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
  40. // | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
  41. // | POSSIBILITY OF SUCH DAMAGE.                                          |
  42. // +----------------------------------------------------------------------+
  43. // | Author: Lukas Smith <smith@pooteeweet.org>                           |
  44. // +----------------------------------------------------------------------+
  45.  
  46. // $Id: oci8.php,v 1.141 2006/05/13 15:40:32 lsmith Exp $
  47.  
  48. /**
  49.  * MDB2 OCI8 driver
  50.  *
  51.  * @package MDB2
  52.  * @category Database
  53.  * @author Lukas Smith <smith@pooteeweet.org>
  54.  */
  55. class MDB2_Driver_oci8 extends MDB2_Driver_Common
  56. {
  57.     // {{{ properties
  58.     var $escape_quotes = "'";
  59.  
  60.     var $uncommitedqueries = 0;
  61.  
  62.     // }}}
  63.     // {{{ constructor
  64.  
  65.     /**
  66.      * Constructor
  67.      */
  68.     function __construct()
  69.     {
  70.         parent::__construct();
  71.  
  72.         $this->phptype 'oci8';
  73.         $this->dbsyntax 'oci8';
  74.  
  75.         $this->supported['sequences'= true;
  76.         $this->supported['indexes'= true;
  77.         $this->supported['summary_functions'= true;
  78.         $this->supported['order_by_text'= true;
  79.         $this->supported['current_id'= true;
  80.         $this->supported['affected_rows'= true;
  81.         $this->supported['transactions'= true;
  82.         $this->supported['limit_queries'= true;
  83.         $this->supported['LOBs'= true;
  84.         $this->supported['replace''emulated';
  85.         $this->supported['sub_selects'= true;
  86.         $this->supported['auto_increment'= false; // implementation is broken
  87.         $this->supported['primary_key'= true;
  88.         $this->supported['result_introspection'= true;
  89.         $this->supported['prepared_statements'= true;
  90.  
  91.         $this->options['DBA_username'= false;
  92.         $this->options['DBA_password'= false;
  93.         $this->options['database_name_prefix'= false;
  94.         $this->options['emulate_database'= true;
  95.         $this->options['default_tablespace'= false;
  96.         $this->options['default_text_field_length'= 2000;
  97.         $this->options['result_prefetching'= false;
  98.     }
  99.  
  100.     // }}}
  101.     // {{{ errorInfo()
  102.  
  103.     /**
  104.      * This method is used to collect information about an error
  105.      *
  106.      * @param integer $error 
  107.      * @return array 
  108.      * @access public
  109.      */
  110.     function errorInfo($error = null)
  111.     {
  112.         if (is_resource($error)) {
  113.             $error_data @OCIError($error);
  114.             $error = null;
  115.         elseif ($this->connection{
  116.             $error_data @OCIError($this->connection);
  117.         else {
  118.             $error_data @OCIError();
  119.         }
  120.         $native_code $error_data['code'];
  121.         $native_msg  $error_data['message'];
  122.         if (is_null($error)) {
  123.             static $ecode_map;
  124.             if (empty($ecode_map)) {
  125.                 $ecode_map = array(
  126.                     1    => MDB2_ERROR_CONSTRAINT,
  127.                     900  => MDB2_ERROR_SYNTAX,
  128.                     904  => MDB2_ERROR_NOSUCHFIELD,
  129.                     913  => MDB2_ERROR_VALUE_COUNT_ON_ROW,
  130.                     921  => MDB2_ERROR_SYNTAX,
  131.                     923  => MDB2_ERROR_SYNTAX,
  132.                     942  => MDB2_ERROR_NOSUCHTABLE,
  133.                     955  => MDB2_ERROR_ALREADY_EXISTS,
  134.                     1400 => MDB2_ERROR_CONSTRAINT_NOT_NULL,
  135.                     1401 => MDB2_ERROR_INVALID,
  136.                     1407 => MDB2_ERROR_CONSTRAINT_NOT_NULL,
  137.                     1418 => MDB2_ERROR_NOT_FOUND,
  138.                     1476 => MDB2_ERROR_DIVZERO,
  139.                     1722 => MDB2_ERROR_INVALID_NUMBER,
  140.                     2289 => MDB2_ERROR_NOSUCHTABLE,
  141.                     2291 => MDB2_ERROR_CONSTRAINT,
  142.                     2292 => MDB2_ERROR_CONSTRAINT,
  143.                     2449 => MDB2_ERROR_CONSTRAINT,
  144.                 );
  145.             }
  146.             if (isset($ecode_map[$native_code])) {
  147.                 $error $ecode_map[$native_code];
  148.             }
  149.         }
  150.         return array($error$native_code$native_msg);
  151.     }
  152.  
  153.     // }}}
  154.     // {{{ beginTransaction()
  155.  
  156.     /**
  157.      * Start a transaction.
  158.      *
  159.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  160.      * @access public
  161.      */
  162.     function beginTransaction()
  163.     {
  164.         $this->debug('starting transaction''beginTransaction'false);
  165.         if ($this->in_transaction{
  166.             return MDB2_OK;  //nothing to do
  167.         }
  168.         if (!$this->destructor_registered && $this->opened_persistent{
  169.             $this->destructor_registered = true;
  170.             register_shutdown_function('MDB2_closeOpenTransactions');
  171.         }
  172.         $this->in_transaction = true;
  173.         ++$this->uncommitedqueries;
  174.         return MDB2_OK;
  175.     }
  176.  
  177.     // }}}
  178.     // {{{ commit()
  179.  
  180.     /**
  181.      * Commit the database changes done during a transaction that is in
  182.      * progress.
  183.      *
  184.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  185.      * @access public
  186.      */
  187.     function commit()
  188.     {
  189.         $this->debug('commit transaction''commit');
  190.         if (!$this->in_transaction{
  191.             return $this->raiseError(MDB2_ERROR_INVALIDnullnull,
  192.                 'commit: transaction changes are being auto committed');
  193.         }
  194.         if ($this->uncommitedqueries{
  195.             $connection $this->getConnection();
  196.             if (PEAR::isError($connection)) {
  197.                 return $connection;
  198.             }
  199.             if (!@OCICommit($connection)) {
  200.                 return $this->raiseError(nullnullnull,
  201.                 'commit: Unable to commit transaction');
  202.             }
  203.             $this->uncommitedqueries = 0;
  204.         }
  205.         $this->in_transaction = false;
  206.         return MDB2_OK;
  207.     }
  208.  
  209.     // }}}
  210.     // {{{ rollback()
  211.  
  212.     /**
  213.      * Cancel any database changes done during a transaction that is in
  214.      * progress.
  215.      *
  216.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  217.      * @access public
  218.      */
  219.     function rollback()
  220.     {
  221.         $this->debug('rolling back transaction''rollback'false);
  222.         if (!$this->in_transaction{
  223.             return $this->raiseError(MDB2_ERROR_INVALIDnullnull,
  224.                 'rollback: transactions can not be rolled back when changes are auto committed');
  225.         }
  226.         if ($this->uncommitedqueries{
  227.             $connection $this->getConnection();
  228.             if (PEAR::isError($connection)) {
  229.                 return $connection;
  230.             }
  231.             if (!@OCIRollback($connection)) {
  232.                 return $this->raiseError(nullnullnull,
  233.                 'rollback: Unable to rollback transaction');
  234.             }
  235.             $this->uncommitedqueries = 0;
  236.         }
  237.         $this->in_transaction = false;
  238.         return MDB2_OK;
  239.     }
  240.  
  241.     // }}}
  242.     // {{{ _doConnect()
  243.  
  244.     /**
  245.      * do the grunt work of the connect
  246.      *
  247.      * @return connection on success or MDB2 Error Object on failure
  248.      * @access protected
  249.      */
  250.     function _doConnect($username$password$persistent = false)
  251.     {
  252.         if (!PEAR::loadExtension($this->phptype)) {
  253.             return $this->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  254.                 'extension '.$this->phptype.' is not compiled into PHP');
  255.         }
  256.  
  257.         $sid '';
  258.         if ($this->dsn['hostspec']{
  259.             $sid $this->dsn['hostspec'];
  260.             if (!$this->options['emulate_database'&& $this->database_name{
  261.                 $port $service '';
  262.                 if ($this->dsn['port']{
  263.                     $port ':'.$this->dsn['port'];
  264.                 }
  265.                 $service $this->database_name;
  266.                 if (substr($service01!== '/'{
  267.                     $service '/'.$service;
  268.                 }
  269.                 $sid '//'.$sid.$port.$service;
  270.             }
  271.         elseif (!$this->options['emulate_database'&& $this->database_name{
  272.             $sid $this->database_name;
  273.         else {
  274.             $sid getenv('ORACLE_SID');
  275.         }
  276.  
  277.         if (empty($sid)) {
  278.             return $this->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  279.                 'it was not specified a valid Oracle Service Identifier (SID)');
  280.         }
  281.  
  282.         if (function_exists('oci_connect')) {
  283.             if (isset($this->dsn['new_link'])
  284.                 && ($this->dsn['new_link'== 'true' || $this->dsn['new_link'=== true)
  285.             {
  286.                 $connect_function 'oci_new_connect';
  287.             else {
  288.                 $connect_function $persistent 'oci_pconnect' 'oci_connect';
  289.             }
  290.  
  291.             $charset = empty($this->dsn['charset']? null : $this->dsn['charset'];
  292.             $connection @$connect_function($username$password$sid$charset);
  293.             $error @OCIError();
  294.             if (isset($error['code']&& $error['code'== 12541{
  295.                 // Couldn't find TNS listener.  Try direct connection.
  296.                 $connection @$connect_function($username$passwordnull$charset);
  297.             }
  298.         else {
  299.             if (isset($this->dsn['charset']&& !empty($this->dsn['charset'])) {
  300.                 return $this->raiseError(MDB2_ERROR_UNSUPPORTEDnullnull,
  301.                     'Unable to set client charset: '.$this->dsn['charset']);
  302.             }
  303.  
  304.             $connect_function $persistent 'OCIPLogon' 'OCILogon';
  305.             $connection @$connect_function($username$password$sid);
  306.         }
  307.  
  308.         if (!$connection{
  309.             return $this->raiseError(MDB2_ERROR_CONNECT_FAILED);
  310.         }
  311.  
  312.         $query "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'";
  313.         $err =$this->_doQuery($querytrue$connection);
  314.         if (PEAR::isError($err)) {
  315.             $this->disconnect(false);
  316.             return $err;
  317.         }
  318.  
  319.         $query "ALTER SESSION SET NLS_NUMERIC_CHARACTERS='. '";
  320.         $err =$this->_doQuery($querytrue$connection);
  321.         if (PEAR::isError($err)) {
  322.             $this->disconnect(false);
  323.             return $err;
  324.         }
  325.  
  326.         return $connection;
  327.     }
  328.  
  329.     // }}}
  330.     // {{{ connect()
  331.  
  332.     /**
  333.      * Connect to the database
  334.      *
  335.      * @return MDB2_OK on success, MDB2 Error Object on failure
  336.      * @access public
  337.      */
  338.     function connect()
  339.     {
  340.         if ($this->database_name && $this->options['emulate_database']{
  341.              $this->dsn['username'$this->options['database_name_prefix'].$this->database_name;
  342.         }
  343.         if (is_resource($this->connection)) {
  344.             if (count(array_diff($this->connected_dsn$this->dsn)) == 0
  345.                 && $this->connected_database_name == $this->database_name
  346.                 && $this->opened_persistent == $this->options['persistent']
  347.             {
  348.                 return MDB2_OK;
  349.             }
  350.             $this->disconnect(false);
  351.         }
  352.  
  353.         $connection $this->_doConnect(
  354.             $this->dsn['username'],
  355.             $this->dsn['password'],
  356.             $this->options['persistent']
  357.         );
  358.         if (PEAR::isError($connection)) {
  359.             return $connection;
  360.         }
  361.         $this->connection $connection;
  362.         $this->connected_dsn $this->dsn;
  363.         $this->connected_database_name $this->database_name;
  364.         $this->opened_persistent $this->options['persistent'];
  365.         $this->dbsyntax $this->dsn['dbsyntax'$this->dsn['dbsyntax'$this->phptype;
  366.  
  367.         return MDB2_OK;
  368.     }
  369.  
  370.     // }}}
  371.     // {{{ disconnect()
  372.  
  373.     /**
  374.      * Log out and disconnect from the database.
  375.      *
  376.      * @param  boolean $force if the disconnect should be forced even if the
  377.      *                         connection is opened persistently
  378.      * @return mixed true on success, false if not connected and error
  379.      *                 object on error
  380.      * @access public
  381.      */
  382.     function disconnect($force = true)
  383.     {
  384.         if (is_resource($this->connection)) {
  385.             if ($this->in_transaction{
  386.                 $this->rollback();
  387.             }
  388.             if (!$this->opened_persistent || $force{
  389.                 if (function_exists('oci_close')) {
  390.                     @oci_close($this->connection);
  391.                 else {
  392.                     @OCILogOff($this->connection);
  393.                 }
  394.             }
  395.             $this->uncommitedqueries = 0;
  396.         }
  397.         return parent::disconnect($force);
  398.     }
  399.  
  400.     // }}}
  401.     // {{{ standaloneExec()
  402.  
  403.    /**
  404.      * execute a query as database administrator
  405.      *
  406.      * @param string $query the SQL query
  407.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  408.      * @access public
  409.      */
  410.     function &standaloneExec($query)
  411.     {
  412.         $connection $this->_doConnect(
  413.             $this->options['DBA_username'],
  414.             $this->options['DBA_password'],
  415.             $this->options['persistent']
  416.         );
  417.         if (PEAR::isError($connection)) {
  418.             return $connection;
  419.         }
  420.  
  421.         $offset $this->offset;
  422.         $limit $this->limit;
  423.         $this->offset $this->limit = 0;
  424.         $query $this->_modifyQuery($queryfalse$limit$offset);
  425.  
  426.         $result =$this->_doQuery($queryfalse$connectionfalse);
  427.         @OCILogOff($connection);
  428.         if (PEAR::isError($result)) {
  429.             return $result;
  430.         }
  431.  
  432.         return $this->_affectedRows($connection$result);
  433.     }
  434.  
  435.     // }}}
  436.     // {{{ standaloneQuery()
  437.  
  438.    /**
  439.      * execute a query as DBA
  440.      *
  441.      * @param string $query the SQL query
  442.      * @param mixed   $types  array that contains the types of the columns in
  443.      *                         the result set
  444.      * @param boolean $is_manip  if the query is a manipulation query
  445.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  446.      * @access public
  447.      */
  448.     function &standaloneQuery($query$types = null$is_manip = false)
  449.     {
  450.         $connection $this->_doConnect(
  451.             $this->options['DBA_username'],
  452.             $this->options['DBA_password'],
  453.             $this->options['persistent']
  454.         );
  455.         if (PEAR::isError($connection)) {
  456.             return $connection;
  457.         }
  458.  
  459.         $offset $this->offset;
  460.         $limit $this->limit;
  461.         $this->offset $this->limit = 0;
  462.         $query $this->_modifyQuery($query$is_manip$limit$offset);
  463.  
  464.         $result =$this->_doQuery($query$is_manip$connectionfalse);
  465.         @OCILogOff($connection);
  466.         if (PEAR::isError($result)) {
  467.             return $result;
  468.         }
  469.  
  470.         if ($is_manip{
  471.             $affected_rows =  $this->_affectedRows($connection$result);
  472.             return $affected_rows;
  473.         }
  474.         $return =$this->_wrapResult($result$typestruefalse$limit$offset);
  475.         return $return;
  476.     }
  477.  
  478.     // }}}
  479.     // {{{ _modifyQuery()
  480.  
  481.     /**
  482.      * Changes a query string for various DBMS specific reasons
  483.      *
  484.      * @param string $query  query to modify
  485.      * @param boolean $is_manip  if it is a DML query
  486.      * @param integer $limit  limit the number of rows
  487.      * @param integer $offset  start reading from given offset
  488.      * @return string modified query
  489.      * @access protected
  490.      */
  491.     function _modifyQuery($query$is_manip$limit$offset)
  492.     {
  493.         if (preg_match('/^\s*SELECT/i'$query)) {
  494.             if (!preg_match('/\sFROM\s/i'$query)) {
  495.                 $query.= " FROM dual";
  496.             }
  497.             if ($limit > 0{
  498.                 // taken from http://svn.ez.no/svn/ezcomponents/packages/Database
  499.                 $min $offset + 1;
  500.                 $max $offset $limit;
  501.                 $query = "SELECT * FROM (SELECT a.*, ROWNUM rn FROM ($query) a WHERE ROWNUM <= $max) WHERE rn >= $min";
  502.             }
  503.         }
  504.         return $query;
  505.     }
  506.  
  507.     // }}}
  508.     // {{{ _doQuery()
  509.  
  510.     /**
  511.      * Execute a query
  512.      * @param string $query  query
  513.      * @param boolean $is_manip  if the query is a manipulation query
  514.      * @param resource $connection 
  515.      * @param string $database_name 
  516.      * @return result or error object
  517.      * @access protected
  518.      */
  519.     function &_doQuery($query$is_manip = false$connection = null$database_name = null)
  520.     {
  521.         $this->last_query $query;
  522.         $this->debug($query'query'$is_manip);
  523.         if ($this->getOption('disable_query')) {
  524.             if ($is_manip{
  525.                 return 0;
  526.             }
  527.             return null;
  528.         }
  529.  
  530.         if (is_null($connection)) {
  531.             $connection $this->getConnection();
  532.             if (PEAR::isError($connection)) {
  533.                 return $connection;
  534.             }
  535.         }
  536.  
  537.         $result @OCIParse($connection$query);
  538.         if (!$result{
  539.             $err $this->raiseError(nullnullnull,
  540.                 '_doQuery: Could not create statement');
  541.             return $err;
  542.         }
  543.  
  544.         $mode $this->in_transaction ? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
  545.         if (!@OCIExecute($result$mode)) {
  546.             $err =$this->raiseError($resultnullnull,
  547.                 '_doQuery: Could not execute statement');
  548.             return $err;
  549.         }
  550.  
  551.         if (is_numeric($this->options['result_prefetching'])) {
  552.             @ocisetprefetch($result$this->options['result_prefetching']);
  553.         }
  554.         return $result;
  555.     }
  556.  
  557.     // }}}
  558.     // {{{ _affectedRows()
  559.  
  560.     /**
  561.      * Returns the number of rows affected
  562.      *
  563.      * @param resource $result 
  564.      * @param resource $connection 
  565.      * @return mixed MDB2 Error Object or the number of rows affected
  566.      * @access private
  567.      */
  568.     function _affectedRows($connection$result = null)
  569.     {
  570.         if (is_null($connection)) {
  571.             $connection $this->getConnection();
  572.             if (PEAR::isError($connection)) {
  573.                 return $connection;
  574.             }
  575.         }
  576.         return @OCIRowCount($result);
  577.     }
  578.  
  579.     // }}}
  580.     // {{{ getServerVersion()
  581.  
  582.     /**
  583.      * return version information about the server
  584.      *
  585.      * @param string     $native  determines if the raw version string should be returned
  586.      * @return mixed array/string with version information or MDB2 error object
  587.      * @access public
  588.      */
  589.     function getServerVersion($native = false)
  590.     {
  591.         $connection $this->getConnection();
  592.         if (PEAR::isError($connection)) {
  593.             return $connection;
  594.         }
  595.         if ($this->connected_server_info{
  596.             $server_info $this->connected_server_info;
  597.         else {
  598.             $server_info @ociserverversion($connection);
  599.         }
  600.         if (!$server_info{
  601.             return $this->raiseError(nullnullnull,
  602.                 'getServerVersion: Could not get server information');
  603.         }
  604.         // cache server_info
  605.         $this->connected_server_info $server_info;
  606.         if (!$native{
  607.             if (!preg_match('/ (\d+)\.(\d+)\.(\d+)\.([\d\.]+) /'$server_info$tmp)) {
  608.                 return $this->raiseError(MDB2_ERROR_INVALIDnullnull,
  609.                     'Could not parse version information:'.$server_info);
  610.             }
  611.             $server_info = array(
  612.                 'major' => $tmp[1],
  613.                 'minor' => $tmp[2],
  614.                 'patch' => $tmp[3],
  615.                 'extra' => $tmp[4],
  616.                 'native' => $server_info,
  617.             );
  618.         }
  619.         return $server_info;
  620.     }
  621.  
  622.     // }}}
  623.     // {{{ prepare()
  624.  
  625.     /**
  626.      * Prepares a query for multiple execution with execute().
  627.      * With some database backends, this is emulated.
  628.      * prepare() requires a generic query as string like
  629.      * 'INSERT INTO numbers VALUES(?,?)' or
  630.      * 'INSERT INTO numbers VALUES(:foo,:bar)'.
  631.      * The ? and :[a-zA-Z] and  are placeholders which can be set using
  632.      * bindParam() and the query can be send off using the execute() method.
  633.      *
  634.      * @param string $query the query to prepare
  635.      * @param mixed   $types  array that contains the types of the placeholders
  636.      * @param mixed   $result_types  array that contains the types of the columns in
  637.      *                         the result set or MDB2_PREPARE_RESULT, if set to
  638.      *                         MDB2_PREPARE_MANIP the query is handled as a manipulation query
  639.      * @param mixed   $lobs   key (field) value (parameter) pair for all lob placeholders
  640.      * @return mixed resource handle for the prepared query on success, a MDB2
  641.      *         error on failure
  642.      * @access public
  643.      * @see bindParam, execute
  644.      */
  645.     function &prepare($query$types = null$result_types = null$lobs = array())
  646.     {
  647.         $is_manip ($result_types === MDB2_PREPARE_MANIP);
  648.         $offset $this->offset;
  649.         $limit $this->limit;
  650.         $this->offset $this->limit = 0;
  651.         $this->debug($query'prepare'$is_manip);
  652.         $query $this->_modifyQuery($query$is_manip$limit$offset);
  653.         $placeholder_type_guess $placeholder_type = null;
  654.         $question '?';
  655.         $colon ':';
  656.         $positions = array();
  657.         $position = 0;
  658.         $parameter = -1;
  659.         while ($position strlen($query)) {
  660.             $q_position strpos($query$question$position);
  661.             $c_position strpos($query$colon$position);
  662.             if ($q_position && $c_position{
  663.                 $p_position min($q_position$c_position);
  664.             elseif ($q_position{
  665.                 $p_position $q_position;
  666.             elseif ($c_position{
  667.                 $p_position $c_position;
  668.             else {
  669.                 break;
  670.             }
  671.             if (is_null($placeholder_type)) {
  672.                 $placeholder_type_guess $query[$p_position];
  673.             }
  674.             if (is_int($quote strpos($query"'"$position)) && $quote $p_position{
  675.                 if (!is_int($end_quote strpos($query"'"$quote + 1))) {
  676.                     $err =$this->raiseError(MDB2_ERROR_SYNTAXnullnull,
  677.                         'prepare: query with an unterminated text string specified');
  678.                     return $err;
  679.                 }
  680.                 switch ($this->escape_quotes{
  681.                 case '':
  682.                 case "'":
  683.                     $position $end_quote + 1;
  684.                     break;
  685.                 default:
  686.                     if ($end_quote == $quote + 1{
  687.                         $position $end_quote + 1;
  688.                     else {
  689.                         if ($query[$end_quote-1== $this->escape_quotes{
  690.                             $position $end_quote;
  691.                         else {
  692.                             $position $end_quote + 1;
  693.                         }
  694.                     }
  695.                     break;
  696.                 }
  697.             elseif ($query[$position== $placeholder_type_guess{
  698.                 if (is_null($placeholder_type)) {
  699.                     $placeholder_type $query[$p_position];
  700.                     $question $colon $placeholder_type;
  701.                     if (is_array($types&& !empty($types)) {
  702.                         if ($placeholder_type == ':'{
  703.                             if (is_int(key($types))) {
  704.                                 $types_tmp $types;
  705.                                 $types = array();
  706.                                 $count = -1;
  707.                             }
  708.                         else {
  709.                             $types array_values($types);
  710.                         }
  711.                     }
  712.                 }
  713.                 if ($placeholder_type == ':'{
  714.                     $parameter preg_replace('/^.{'.($position+1).'}([a-z0-9_]+).*$/si''\\1'$query);
  715.                     if ($parameter === ''{
  716.                         $err =$this->raiseError(MDB2_ERROR_SYNTAXnullnull,
  717.                             'prepare: named parameter with an empty name');
  718.                         return $err;
  719.                     }
  720.                     // use parameter name in type array
  721.                     if (isset($count&& isset($types_tmp[++$count])) {
  722.                         $types[$parameter$types_tmp[$count];
  723.                     }
  724.                     $length strlen($parameter+ 1;
  725.                 else {
  726.                     ++$parameter;
  727.                     $length strlen($parameter);
  728.                 }
  729.                 $positions[$parameter$p_position;
  730.                 if (isset($types[$parameter])
  731.                     && ($types[$parameter== 'clob' || $types[$parameter== 'blob')
  732.                 {
  733.                     if (!isset($lobs[$parameter])) {
  734.                         $lobs[$parameter$parameter;
  735.                     }
  736.                     $value $this->quote(true$types[$parameter]);
  737.                     $query substr_replace($query$value$p_position$length);
  738.                     $position $p_position strlen($value- 1;
  739.                 elseif ($placeholder_type == '?'{
  740.                     $query substr_replace($query':'.$parameter$p_position1);
  741.                     $position $p_position $length;
  742.                 else {
  743.                     $position $p_position + 1;
  744.                 }
  745.             else {
  746.                 $position $p_position;
  747.             }
  748.         }
  749.         if (is_array($lobs)) {
  750.             $columns $variables '';
  751.             foreach ($lobs as $parameter => $field{
  752.                 $columns.= ($columns ', ' ' RETURNING ').$field;
  753.                 $variables.= ($variables ', ' ' INTO ').':'.$parameter;
  754.             }
  755.             $query.= $columns.$variables;
  756.         }
  757.         $connection $this->getConnection();
  758.         if (PEAR::isError($connection)) {
  759.             return $connection;
  760.         }
  761.         $statement @OCIParse($connection$query);
  762.         if (!$statement{
  763.             $err =$this->raiseError(nullnullnull,
  764.                 'Could not create statement');
  765.             return $err;
  766.         }
  767.  
  768.         $class_name 'MDB2_Statement_'.$this->phptype;
  769.         $obj =new $class_name($this$statement$positions$query$types$result_types$is_manip$limit$offset);
  770.         return $obj;
  771.     }
  772.  
  773.     // }}}
  774.     // {{{ nextID()
  775.  
  776.     /**
  777.      * Returns the next free id of a sequence
  778.      *
  779.      * @param string $seq_name name of the sequence
  780.      * @param boolean $ondemand when true the sequence is
  781.      *                            automatic created, if it
  782.      *                            not exists
  783.      * @return mixed MDB2 Error Object or id
  784.      * @access public
  785.      */
  786.     function nextID($seq_name$ondemand = true)
  787.     {
  788.         $sequence_name $this->quoteIdentifier($this->getSequenceName($seq_name)true);
  789.         $query = "SELECT $sequence_name.nextval FROM DUAL";
  790.         $this->expectError(MDB2_ERROR_NOSUCHTABLE);
  791.         $result $this->queryOne($query'integer');
  792.         $this->popExpect();
  793.         if (PEAR::isError($result)) {
  794.             if ($ondemand && $result->getCode(== MDB2_ERROR_NOSUCHTABLE{
  795.                 $this->loadModule('Manager'nulltrue);
  796.                 $result $this->manager->createSequence($seq_name1);
  797.                 if (PEAR::isError($result)) {
  798.                     return $result;
  799.                 }
  800.                 return $this->nextId($seq_namefalse);
  801.             }
  802.         }
  803.         return $result;
  804.     }
  805.  
  806.     // }}}
  807.     // {{{ currId()
  808.  
  809.     /**
  810.      * Returns the current id of a sequence
  811.      *
  812.      * @param string $seq_name name of the sequence
  813.      * @return mixed MDB2_Error or id
  814.      * @access public
  815.      */
  816.     function currId($seq_name)
  817.     {
  818.         $sequence_name $this->quoteIdentifier($this->getSequenceName($seq_name)true);
  819.         return $this->queryOne("SELECT $sequence_name.currval FROM DUAL");
  820.     }
  821. }
  822.  
  823. /**
  824.  * MDB2 OCI8 result driver
  825.  *
  826.  * @package MDB2
  827.  * @category Database
  828.  * @author Lukas Smith <smith@pooteeweet.org>
  829.  */
  830. class MDB2_Result_oci8 extends MDB2_Result_Common
  831. {
  832.     // }}}
  833.     // {{{ fetchRow()
  834.  
  835.     /**
  836.      * Fetch a row and insert the data into an existing array.
  837.      *
  838.      * @param int       $fetchmode  how the array data should be indexed
  839.      * @param int    $rownum    number of the row where the data can be found
  840.      * @return int data array on success, a MDB2 error on failure
  841.      * @access public
  842.      */
  843.     function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT$rownum = null)
  844.     {
  845.         if (!is_null($rownum)) {
  846.             $seek $this->seek($rownum);
  847.             if (PEAR::isError($seek)) {
  848.                 return $seek;
  849.             }
  850.         }
  851.         if ($fetchmode == MDB2_FETCHMODE_DEFAULT{
  852.             $fetchmode $this->db->fetchmode;
  853.         }
  854.         if ($fetchmode MDB2_FETCHMODE_ASSOC{
  855.             @OCIFetchInto($this->result$rowOCI_ASSOC+OCI_RETURN_NULLS);
  856.             if (is_array($row)
  857.                 && $this->db->options['portability'MDB2_PORTABILITY_FIX_CASE
  858.             {
  859.                 $row array_change_key_case($row$this->db->options['field_case']);
  860.             }
  861.         else {
  862.             @OCIFetchInto($this->result$rowOCI_RETURN_NULLS);
  863.         }
  864.         if (!$row{
  865.             if ($this->result === false{
  866.                 $err =$this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  867.                     'fetchRow: resultset has already been freed');
  868.                 return $err;
  869.             }
  870.             $null = null;
  871.             return $null;
  872.  
  873.         }
  874.         if ($this->db->options['portability'MDB2_PORTABILITY_RTRIM{
  875.             $this->db->_fixResultArrayValues($rowMDB2_PORTABILITY_RTRIM);
  876.         }
  877.         if (!empty($this->values)) {
  878.             $this->_assignBindColumns($row);
  879.         }
  880.         if (!empty($this->types)) {
  881.             $row $this->db->datatype->convertResultRow($this->types$row);
  882.         }
  883.         if ($fetchmode === MDB2_FETCHMODE_OBJECT{
  884.             $object_class $this->db->options['fetch_class'];
  885.             if ($object_class == 'stdClass'{
  886.                 $row = (object) $row;
  887.             else {
  888.                 $row &new $object_class($row);
  889.             }
  890.         }
  891.         ++$this->rownum;
  892.         return $row;
  893.     }
  894.  
  895.     // }}}
  896.     // {{{ _getColumnNames()
  897.  
  898.     /**
  899.      * Retrieve the names of columns returned by the DBMS in a query result.
  900.      *
  901.      * @return mixed associative array variable
  902.      *       that holds the names of columns. The indexes of the array are
  903.      *       the column names mapped to lower case and the values are the
  904.      *       respective numbers of the columns starting from 0. Some DBMS may
  905.      *       not return any columns when the result set does not contain any
  906.      *       rows.
  907.      * @access private
  908.      */
  909.     function _getColumnNames()
  910.     {
  911.         $columns = array();
  912.         $numcols $this->numCols();
  913.         if (PEAR::isError($numcols)) {
  914.             return $numcols;
  915.         }
  916.         for ($column = 0; $column $numcols$column++{
  917.             $column_name @OCIColumnName($this->result$column + 1);
  918.             $columns[$column_name$column;
  919.         }
  920.         if ($this->db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  921.             $columns array_change_key_case($columns$this->db->options['field_case']);
  922.         }
  923.         return $columns;
  924.     }
  925.  
  926.     // }}}
  927.     // {{{ numCols()
  928.  
  929.     /**
  930.      * Count the number of columns returned by the DBMS in a query result.
  931.      *
  932.      * @return mixed integer value with the number of columns, a MDB2 error
  933.      *       on failure
  934.      * @access public
  935.      */
  936.     function numCols()
  937.     {
  938.         $cols @OCINumCols($this->result);
  939.         if (is_null($cols)) {
  940.             if ($this->result === false{
  941.                 return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  942.                     'numCols: resultset has already been freed');
  943.             elseif (is_null($this->result)) {
  944.                 return count($this->types);
  945.             }
  946.             return $this->db->raiseError(nullnullnull,
  947.                 'numCols: Could not get column count');
  948.         }
  949.         return $cols;
  950.     }
  951.  
  952.     // }}}
  953.     // {{{ free()
  954.  
  955.     /**
  956.      * Free the internal resources associated with $result.
  957.      *
  958.      * @return boolean true on success, false if $result is invalid
  959.      * @access public
  960.      */
  961.     function free()
  962.     {
  963.         $free @OCIFreeCursor($this->result);
  964.         if (!$free{
  965.             if (!$this->result{
  966.                 return MDB2_OK;
  967.             }
  968.             return $this->db->raiseError(nullnullnull,
  969.                 'free: Could not free result');
  970.         }
  971.         $this->result = false;
  972.         return MDB2_OK;
  973.     }
  974. }
  975.  
  976. /**
  977.  * MDB2 OCI8 buffered result driver
  978.  *
  979.  * @package MDB2
  980.  * @category Database
  981.  * @author Lukas Smith <smith@pooteeweet.org>
  982.  */
  983. {
  984.     var $buffer;
  985.     var $buffer_rownum = - 1;
  986.  
  987.     // {{{ _fillBuffer()
  988.  
  989.     /**
  990.      * Fill the row buffer
  991.      *
  992.      * @param int $rownum   row number upto which the buffer should be filled
  993.                             if the row number is null all rows are ready into the buffer
  994.      * @return boolean true on success, false on failure
  995.      * @access protected
  996.      */
  997.     function _fillBuffer($rownum = null)
  998.     {
  999.         if (isset($this->buffer&& is_array($this->buffer)) {
  1000.             if (is_null($rownum)) {
  1001.                 if (!end($this->buffer)) {
  1002.                     return false;
  1003.                 }
  1004.             elseif (isset($this->buffer[$rownum])) {
  1005.                 return (bool)$this->buffer[$rownum];
  1006.             }
  1007.         }
  1008.  
  1009.         $row = true;
  1010.         while ((is_null($rownum|| $this->buffer_rownum < $rownum)
  1011.             && ($row @OCIFetchInto($this->result$bufferOCI_RETURN_NULLS))
  1012.         {
  1013.             ++$this->buffer_rownum;
  1014.             $this->buffer[$this->buffer_rownum$buffer;
  1015.         }
  1016.  
  1017.         if (!$row{
  1018.             ++$this->buffer_rownum;
  1019.             $this->buffer[$this->buffer_rownum= false;
  1020.             return false;
  1021.         }
  1022.         return true;
  1023.     }
  1024.  
  1025.     // }}}
  1026.     // {{{ fetchRow()
  1027.  
  1028.     /**
  1029.      * Fetch a row and insert the data into an existing array.
  1030.      *
  1031.      * @param int       $fetchmode  how the array data should be indexed
  1032.      * @param int    $rownum    number of the row where the data can be found
  1033.      * @return int data array on success, a MDB2 error on failure
  1034.      * @access public
  1035.      */
  1036.     function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT$rownum = null)
  1037.     {
  1038.         if ($this->result === false{
  1039.             $err =$this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1040.                 'fetchRow: resultset has already been freed');
  1041.             return $err;
  1042.         elseif (is_null($this->result)) {
  1043.             return null;
  1044.         }
  1045.         if (!is_null($rownum)) {
  1046.             $seek $this->seek($rownum);
  1047.             if (PEAR::isError($seek)) {
  1048.                 return $seek;
  1049.             }
  1050.         }
  1051.         $target_rownum $this->rownum + 1;
  1052.         if ($fetchmode == MDB2_FETCHMODE_DEFAULT{
  1053.             $fetchmode $this->db->fetchmode;
  1054.         }
  1055.         if (!$this->_fillBuffer($target_rownum)) {
  1056.             $null = null;
  1057.             return $null;
  1058.         }
  1059.         $row $this->buffer[$target_rownum];
  1060.         if ($fetchmode MDB2_FETCHMODE_ASSOC{
  1061.             $column_names $this->getColumnNames();
  1062.             foreach ($column_names as $name => $i{
  1063.                 $column_names[$name$row[$i];
  1064.             }
  1065.             $row $column_names;
  1066.         }
  1067.         if (!empty($this->values)) {
  1068.             $this->_assignBindColumns($row);
  1069.         }
  1070.         if (!empty($this->types)) {
  1071.             $row $this->db->datatype->convertResultRow($this->types$row);
  1072.         }
  1073.         if ($this->db->options['portability'MDB2_PORTABILITY_RTRIM{
  1074.             $this->db->_fixResultArrayValues($rowMDB2_PORTABILITY_RTRIM);
  1075.         }
  1076.         if ($fetchmode === MDB2_FETCHMODE_OBJECT{
  1077.             $object_class $this->db->options['fetch_class'];
  1078.             if ($object_class == 'stdClass'{
  1079.                 $row = (object) $row;
  1080.             else {
  1081.                 $row &new $object_class($row);
  1082.             }
  1083.         }
  1084.         ++$this->rownum;
  1085.         return $row;
  1086.     }
  1087.  
  1088.     // }}}
  1089.     // {{{ seek()
  1090.  
  1091.     /**
  1092.      * Seek to a specific row in a result set
  1093.      *
  1094.      * @param int    $rownum    number of the row where the data can be found
  1095.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  1096.      * @access public
  1097.      */
  1098.     function seek($rownum = 0)
  1099.     {
  1100.         if ($this->result === false{
  1101.             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1102.                 'seek: resultset has already been freed');
  1103.         }
  1104.         $this->rownum $rownum - 1;
  1105.         return MDB2_OK;
  1106.     }
  1107.  
  1108.     // }}}
  1109.     // {{{ valid()
  1110.  
  1111.     /**
  1112.      * Check if the end of the result set has been reached
  1113.      *
  1114.      * @return mixed true or false on sucess, a MDB2 error on failure
  1115.      * @access public
  1116.      */
  1117.     function valid()
  1118.     {
  1119.         if ($this->result === false{
  1120.             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1121.                 'valid: resultset has already been freed');
  1122.         elseif (is_null($this->result)) {
  1123.             return true;
  1124.         }
  1125.         if ($this->_fillBuffer($this->rownum + 1)) {
  1126.             return true;
  1127.         }
  1128.         return false;
  1129.     }
  1130.  
  1131.     // }}}
  1132.     // {{{ numRows()
  1133.  
  1134.     /**
  1135.      * Returns the number of rows in a result object
  1136.      *
  1137.      * @return mixed MDB2 Error Object or the number of rows
  1138.      * @access public
  1139.      */
  1140.     function numRows()
  1141.     {
  1142.         if ($this->result === false{
  1143.             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1144.                 'numRows: resultset has already been freed');
  1145.         elseif (is_null($this->result)) {
  1146.             return 0;
  1147.         }
  1148.         $this->_fillBuffer();
  1149.         return $this->buffer_rownum;
  1150.     }
  1151.  
  1152.     // }}}
  1153.     // {{{ free()
  1154.  
  1155.     /**
  1156.      * Free the internal resources associated with $result.
  1157.      *
  1158.      * @return boolean true on success, false if $result is invalid
  1159.      * @access public
  1160.      */
  1161.     function free()
  1162.     {
  1163.         $this->buffer = null;
  1164.         $this->buffer_rownum = null;
  1165.         $free = parent::free();
  1166.     }
  1167. }
  1168.  
  1169. /**
  1170.  * MDB2 OCI8 statement driver
  1171.  *
  1172.  * @package MDB2
  1173.  * @category Database
  1174.  * @author Lukas Smith <smith@pooteeweet.org>
  1175.  */
  1176. class MDB2_Statement_oci8 extends MDB2_Statement_Common
  1177. {
  1178.     // }}}
  1179.     // {{{ _execute()
  1180.  
  1181.     /**
  1182.      * Execute a prepared query statement helper method.
  1183.      *
  1184.      * @param mixed $result_class string which specifies which result class to use
  1185.      * @param mixed $result_wrap_class string which specifies which class to wrap results in
  1186.      * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  1187.      * @access private
  1188.      */
  1189.     function &_execute($result_class = true$result_wrap_class = false)
  1190.     {
  1191.         $this->db->last_query = $this->query;
  1192.         $this->db->debug($this->query'execute'$this->is_manip);
  1193.         $this->db->debug($this->values'parameters'$this->is_manip);
  1194.         if ($this->db->getOption('disable_query')) {
  1195.             if ($this->is_manip{
  1196.                 $return = 0;
  1197.                 return $return;
  1198.             }
  1199.             $null = null;
  1200.             return $null;
  1201.         }
  1202.  
  1203.         $connection $this->db->getConnection();
  1204.         if (PEAR::isError($connection)) {
  1205.             return $connection;
  1206.         }
  1207.  
  1208.         $result = MDB2_OK;
  1209.         $lobs $quoted_values = array();
  1210.         $i = 0;
  1211.         foreach ($this->positions as $parameter => $current_position{
  1212.             if (!array_key_exists($parameter$this->values)) {
  1213.                 return $this->db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  1214.                     '_execute: Unable to bind to missing placeholder: '.$parameter);
  1215.             }
  1216.             $value $this->values[$parameter];
  1217.             $type array_key_exists($parameter$this->types$this->types[$parameter: null;
  1218.             if ($type == 'clob' || $type == 'blob'{
  1219.                 $lobs[$i]['file'= false;
  1220.                 if (is_resource($value)) {
  1221.                     $fp $value;
  1222.                     $value '';
  1223.                     while (!feof($fp)) {
  1224.                         $value.= fread($fp8192);
  1225.                     }
  1226.                 elseif (preg_match('/^(\w+:\/\/)(.*)$/'$value$match)) {
  1227.                     $lobs[$i]['file'= true;
  1228.                     if ($match[1== 'file://'{
  1229.                         $value $match[2];
  1230.                     }
  1231.                 }
  1232.                 $lobs[$i]['value'$value;
  1233.                 $lobs[$i]['descriptor'@OCINewDescriptor($connectionOCI_D_LOB);
  1234.                 if (!is_object($lobs[$i]['descriptor'])) {
  1235.                     $result $this->db->raiseError(nullnullnull,
  1236.                         '_execute: Unable to create descriptor for LOB in parameter: '.$parameter);
  1237.                     break;
  1238.                 }
  1239.                 $lob_type ($type == 'blob' ? OCI_B_BLOB : OCI_B_CLOB);
  1240.                 if (!@OCIBindByName($this->statement':'.$parameter$lobs[$i]['descriptor']-1$lob_type)) {
  1241.                     $result $this->db->raiseError($this->statement);
  1242.                     break;
  1243.                 }
  1244.             else {
  1245.                 $quoted_values[$i$this->db->quote($value$typefalse);
  1246.                 if (PEAR::isError($quoted_values[$i])) {
  1247.                     return $quoted_values[$i];
  1248.                 }
  1249.                 if (!@OCIBindByName($this->statement':'.$parameter$quoted_values[$i])) {
  1250.                     $result $this->db->raiseError($this->statement);
  1251.                     break;
  1252.                 }
  1253.             }
  1254.             ++$i;
  1255.         }
  1256.  
  1257.         $lob_keys array_keys($lobs);
  1258.         if (!PEAR::isError($result)) {
  1259.             $mode (!empty($lobs|| $this->db->in_transaction? OCI_DEFAULT : OCI_COMMIT_ON_SUCCESS;
  1260.             if (!@OCIExecute($this->statement$mode)) {
  1261.                 $err =$this->db->raiseError($this->statement);
  1262.                 return $err;
  1263.             }
  1264.  
  1265.             if (!empty($lobs)) {
  1266.                 foreach ($lob_keys as $i{
  1267.                     if (!is_null($lobs[$i]['value']&& $lobs[$i]['value'!== ''{
  1268.                         if ($lobs[$i]['file']{
  1269.                             $result $lobs[$i]['descriptor']->savefile($lobs[$i]['value']);
  1270.                         else {
  1271.                             $result $lobs[$i]['descriptor']->save($lobs[$i]['value']);
  1272.                         }
  1273.                         if (!$result{
  1274.                             $result $this->db->raiseError(nullnullnull,
  1275.                                 '_execute: Unable to save descriptor contents');
  1276.                             break;
  1277.                         }
  1278.                     }
  1279.                 }
  1280.  
  1281.                 if (!PEAR::isError($result)) {
  1282.                     if (!$this->db->in_transaction{
  1283.                         if (!@OCICommit($connection)) {
  1284.                             $result $this->db->raiseError(nullnullnull,
  1285.                                 '_execute: Unable to commit transaction');
  1286.                         }
  1287.                     else {
  1288.                         ++$this->db->uncommitedqueries;
  1289.                     }
  1290.                 }
  1291.             }
  1292.         }
  1293.  
  1294.         $lob_keys array_keys($lobs);
  1295.         foreach ($lob_keys as $i{
  1296.             $lobs[$i]['descriptor']->free();
  1297.         }
  1298.  
  1299.         if (PEAR::isError($result)) {
  1300.             return $result;
  1301.         }
  1302.  
  1303.         if ($this->is_manip{
  1304.             $affected_rows $this->db->_affectedRows($connection$this->statement);
  1305.             return $affected_rows;
  1306.         }
  1307.  
  1308.         $result =$this->db->_wrapResult($this->statement$this->result_types,
  1309.             $result_class$result_wrap_class);
  1310.         return $result;
  1311.     }
  1312.  
  1313.     // }}}
  1314.     // {{{ free()
  1315.  
  1316.     /**
  1317.      * Release resources allocated for the specified prepared query.
  1318.      *
  1319.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  1320.      * @access public
  1321.      */
  1322.     function free()
  1323.     {
  1324.         if (!@OCIFreeStatement($this->statement)) {
  1325.             return $this->db->raiseError(nullnullnull,
  1326.                 'free: Could not free statement');
  1327.         }
  1328.         return MDB2_OK;
  1329.     }
  1330. }
  1331. ?>

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