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

Source for file ibase.php

Documentation is available at ibase.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: Lorenzo Alberton <l.alberton@quipo.it>                       |
  44. // +----------------------------------------------------------------------+
  45. //
  46. // $Id: ibase.php,v 1.156 2006/05/13 15:08:46 lsmith Exp $
  47.  
  48. /**
  49.  * MDB2 FireBird/InterBase driver
  50.  *
  51.  * @package MDB2
  52.  * @category Database
  53.  * @author  Lorenzo Alberton <l.alberton@quipo.it>
  54.  */
  55. class MDB2_Driver_ibase extends MDB2_Driver_Common
  56. {
  57.     // {{{ properties
  58.     var $escape_quotes = "'";
  59.  
  60.     var $transaction_id = 0;
  61.  
  62.     var $query_parameters = array();
  63.     var $query_parameter_values = array();
  64.  
  65.     // }}}
  66.     // {{{ constructor
  67.  
  68.     /**
  69.      * Constructor
  70.      */
  71.     function __construct()
  72.     {
  73.         parent::__construct();
  74.  
  75.         $this->phptype  'ibase';
  76.         $this->dbsyntax 'ibase';
  77.  
  78.         $this->supported['sequences'= true;
  79.         $this->supported['indexes'= true;
  80.         $this->supported['affected_rows'function_exists('ibase_affected_rows');
  81.         $this->supported['summary_functions'= true;
  82.         $this->supported['order_by_text'= true;
  83.         $this->supported['transactions'= true;
  84.         $this->supported['current_id'= true;
  85.         $this->supported['limit_queries''emulated';
  86.         $this->supported['LOBs'= true;
  87.         $this->supported['replace'= false;
  88.         $this->supported['sub_selects'= true;
  89.         $this->supported['auto_increment'= true;
  90.         $this->supported['primary_key'= true;
  91.         $this->supported['result_introspection'= true;
  92.         $this->supported['prepared_statements'= true;
  93.  
  94.         $this->options['DBA_username'= false;
  95.         $this->options['DBA_password'= false;
  96.         $this->options['database_path''';
  97.         $this->options['database_extension''.gdb';
  98.         $this->options['server_version''';
  99.     }
  100.  
  101.     // }}}
  102.     // {{{ errorInfo()
  103.  
  104.     /**
  105.      * This method is used to collect information about an error
  106.      *
  107.      * @param integer $error 
  108.      * @return array 
  109.      * @access public
  110.      */
  111.     function errorInfo($error = null)
  112.     {
  113.         $native_msg @ibase_errmsg();
  114.  
  115.         if (function_exists('ibase_errcode')) {
  116.             $native_code @ibase_errcode();
  117.         else {
  118.             // memo for the interbase php module hackers: we need something similar
  119.             // to mysql_errno() to retrieve error codes instead of this ugly hack
  120.             if (preg_match('/^([^0-9\-]+)([0-9\-]+)\s+(.*)$/'$native_msg$m)) {
  121.                 $native_code = (int)$m[2];
  122.             else {
  123.                 $native_code = null;
  124.             }
  125.         }
  126.         if (is_null($error)) {
  127.             $error = MDB2_ERROR;
  128.             if ($native_code{
  129.                 // try to interpret Interbase error code (that's why we need ibase_errno()
  130.                 // in the interbase module to return the real error code)
  131.                 switch ($native_code{
  132.                 case -204:
  133.                     if (isset($m[3]&& is_int(strpos($m[3]'Table unknown'))) {
  134.                         $errno = MDB2_ERROR_NOSUCHTABLE;
  135.                     }
  136.                 break;
  137.                 default:
  138.                     static $ecode_map;
  139.                     if (empty($ecode_map)) {
  140.                         $ecode_map = array(
  141.                             -104 => MDB2_ERROR_SYNTAX,
  142.                             -150 => MDB2_ERROR_ACCESS_VIOLATION,
  143.                             -151 => MDB2_ERROR_ACCESS_VIOLATION,
  144.                             -155 => MDB2_ERROR_NOSUCHTABLE,
  145.                             -157 => MDB2_ERROR_NOSUCHFIELD,
  146.                             -158 => MDB2_ERROR_VALUE_COUNT_ON_ROW,
  147.                             -170 => MDB2_ERROR_MISMATCH,
  148.                             -171 => MDB2_ERROR_MISMATCH,
  149.                             -172 => MDB2_ERROR_INVALID,
  150.                             // -204 =>  // Covers too many errors, need to use regex on msg
  151.                             -205 => MDB2_ERROR_NOSUCHFIELD,
  152.                             -206 => MDB2_ERROR_NOSUCHFIELD,
  153.                             -208 => MDB2_ERROR_INVALID,
  154.                             -219 => MDB2_ERROR_NOSUCHTABLE,
  155.                             -297 => MDB2_ERROR_CONSTRAINT,
  156.                             -303 => MDB2_ERROR_INVALID,
  157.                             -413 => MDB2_ERROR_INVALID_NUMBER,
  158.                             -530 => MDB2_ERROR_CONSTRAINT,
  159.                             -551 => MDB2_ERROR_ACCESS_VIOLATION,
  160.                             -552 => MDB2_ERROR_ACCESS_VIOLATION,
  161.                             // -607 =>  // Covers too many errors, need to use regex on msg
  162.                             -625 => MDB2_ERROR_CONSTRAINT_NOT_NULL,
  163.                             -803 => MDB2_ERROR_CONSTRAINT,
  164.                             -804 => MDB2_ERROR_VALUE_COUNT_ON_ROW,
  165.                             -904 => MDB2_ERROR_CONNECT_FAILED,
  166.                             -922 => MDB2_ERROR_NOSUCHDB,
  167.                             -923 => MDB2_ERROR_CONNECT_FAILED,
  168.                             -924 => MDB2_ERROR_CONNECT_FAILED
  169.                         );
  170.                     }
  171.                     if (isset($ecode_map[$native_code])) {
  172.                         $error $ecode_map[$native_code];
  173.                     }
  174.                     break;
  175.                 }
  176.             else {
  177.                 static $error_regexps;
  178.                 if (!isset($error_regexps)) {
  179.                     $error_regexps = array(
  180.                         '/generator .* is not defined/'
  181.                             => MDB2_ERROR_SYNTAX,  // for compat. w ibase_errcode()
  182.                         '/table.*(not exist|not found|unknown)/i'
  183.                             => MDB2_ERROR_NOSUCHTABLE,
  184.                         '/table .* already exists/i'
  185.                             => MDB2_ERROR_ALREADY_EXISTS,
  186.                         '/unsuccessful metadata update .* failed attempt to store duplicate value/i'
  187.                             => MDB2_ERROR_ALREADY_EXISTS,
  188.                         '/unsuccessful metadata update .* not found/i'
  189.                             => MDB2_ERROR_NOT_FOUND,
  190.                         '/validation error for column .* value "\*\*\* null/i'
  191.                             => MDB2_ERROR_CONSTRAINT_NOT_NULL,
  192.                         '/violation of [\w ]+ constraint/i'
  193.                             => MDB2_ERROR_CONSTRAINT,
  194.                         '/conversion error from string/i'
  195.                             => MDB2_ERROR_INVALID_NUMBER,
  196.                         '/no permission for/i'
  197.                             => MDB2_ERROR_ACCESS_VIOLATION,
  198.                         '/arithmetic exception, numeric overflow, or string truncation/i'
  199.                             => MDB2_ERROR_INVALID,
  200.                     );
  201.                 }
  202.                 foreach ($error_regexps as $regexp => $code{
  203.                     if (preg_match($regexp$native_msg$m)) {
  204.                         $error $code;
  205.                         break;
  206.                     }
  207.                 }
  208.             }
  209.         }
  210.         return array($error$native_code$native_msg);
  211.     }
  212.  
  213.     // }}}
  214.     // {{{ quoteIdentifier()
  215.  
  216.     /**
  217.      * Delimited identifiers are a nightmare with InterBase, so they're disabled
  218.      *
  219.      * @param string $str  identifier name to be quoted
  220.      * @param bool   $check_option  check the 'quote_identifier' option
  221.      *
  222.      * @return string  quoted identifier string
  223.      *
  224.      * @access public
  225.      */
  226.     function quoteIdentifier($str$check_option = false)
  227.     {
  228.         if ($check_option && !$this->options['quote_identifier']{
  229.             return $str;
  230.         }
  231.         return strtoupper($str);
  232.     }
  233.  
  234.     // }}}
  235.     // {{{ getConnection()
  236.  
  237.     /**
  238.      * Returns a native connection
  239.      *
  240.      * @return  mixed   a valid MDB2 connection object,
  241.      *                   or a MDB2 error object on error
  242.      * @access  public
  243.      */
  244.     function getConnection()
  245.     {
  246.         $result $this->connect();
  247.         if (PEAR::isError($result)) {
  248.             return $result;
  249.         }
  250.         if ($this->in_transaction{
  251.             return $this->transaction_id;
  252.         }
  253.         return $this->connection;
  254.     }
  255.  
  256.     // }}}
  257.     // {{{ beginTransaction()
  258.  
  259.     /**
  260.      * Start a transaction.
  261.      *
  262.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  263.      * @access public
  264.      */
  265.     function beginTransaction()
  266.     {
  267.         $this->debug('starting transaction''beginTransaction'false);
  268.         if ($this->in_transaction{
  269.             return MDB2_OK;  //nothing to do
  270.         }
  271.         $connection $this->getConnection();
  272.         if (PEAR::isError($connection)) {
  273.             return $connection;
  274.         }
  275.         $result @ibase_trans(IBASE_DEFAULT$connection);
  276.         if (!$result{
  277.             return $this->raiseError(nullnullnull,
  278.                 'beginTransaction: could not start a transaction');
  279.         }
  280.         $this->transaction_id = $result;
  281.         $this->in_transaction = true;
  282.         return MDB2_OK;
  283.     }
  284.  
  285.     // }}}
  286.     // {{{ commit()
  287.  
  288.     /**
  289.      * Commit the database changes done during a transaction that is in
  290.      * progress.
  291.      *
  292.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  293.      * @access public
  294.      */
  295.     function commit()
  296.     {
  297.         $this->debug('commit transaction''commit'false);
  298.         if (!$this->in_transaction{
  299.             return $this->raiseError(MDB2_ERROR_INVALIDnullnull,
  300.                 'commit: transaction changes are being auto committed');
  301.         }
  302.         if (!@ibase_commit($this->transaction_id)) {
  303.             return $this->raiseError(nullnullnull,
  304.                 'commit: could not commit a transaction');
  305.         }
  306.         $this->in_transaction = false;
  307.         //$this->transaction_id = 0;
  308.         return MDB2_OK;
  309.     }
  310.  
  311.     // }}}
  312.     // {{{ rollback()
  313.  
  314.     /**
  315.      * Cancel any database changes done during a transaction that is in
  316.      * progress.
  317.      *
  318.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  319.      * @access public
  320.      */
  321.     function rollback()
  322.     {
  323.         $this->debug('rolling back transaction''rollback'false);
  324.         if (!$this->in_transaction{
  325.             return $this->raiseError(MDB2_ERROR_INVALIDnullnull,
  326.                 'rollback: transactions can not be rolled back when changes are auto committed');
  327.         }
  328.         if ($this->transaction_id && !@ibase_rollback($this->transaction_id)) {
  329.             return $this->raiseError(nullnullnull,
  330.                 'rollback: Could not rollback a pending transaction');
  331.         }
  332.         $this->in_transaction = false;
  333.         $this->transaction_id = 0;
  334.         return MDB2_OK;
  335.     }
  336.  
  337.     // }}}
  338.     // {{{ getDatabaseFile()
  339.  
  340.     /**
  341.      * Builds the string with path+dbname+extension
  342.      *
  343.      * @return string full database path+file
  344.      * @access protected
  345.      */
  346.     function _getDatabaseFile($database_name)
  347.     {
  348.         if ($database_name == ''{
  349.             return $database_name;
  350.         }
  351.         $ret $this->options['database_path'$database_name;
  352.         if (   strpos($database_name'.fdb'=== false
  353.             && strpos($database_name'.gdb'=== false
  354.         {
  355.             $ret .= $this->options['database_extension'];
  356.         }
  357.         return $ret;
  358.     }
  359.  
  360.     // }}}
  361.     // {{{ _doConnect()
  362.  
  363.     /**
  364.      * Does the grunt work of connecting to the database
  365.      *
  366.      * @return mixed connection resource on success, MDB2 Error Object on failure
  367.      * @access protected
  368.      */
  369.     function _doConnect($database_name$persistent = false)
  370.     {
  371.         $user    $this->dsn['username'];
  372.         $pw      $this->dsn['password'];
  373.         $dbhost  $this->dsn['hostspec'?
  374.             ($this->dsn['hostspec'].':'.$database_name$database_name;
  375.  
  376.         $params = array();
  377.         $params[$dbhost;
  378.         $params[!empty($user$user : null;
  379.         $params[!empty($pw$pw : null;
  380.         $params[= isset($this->dsn['charset']$this->dsn['charset': null;
  381.         $params[= isset($this->dsn['buffers']$this->dsn['buffers': null;
  382.         $params[= isset($this->dsn['dialect']$this->dsn['dialect': null;
  383.         $params[= isset($this->dsn['role'])    $this->dsn['role': null;
  384.  
  385.         $connect_function $persistent 'ibase_pconnect' 'ibase_connect';
  386.  
  387.         $connection @call_user_func_array($connect_function$params);
  388.         if ($connection <= 0{
  389.             return $this->raiseError(MDB2_ERROR_CONNECT_FAILED);
  390.         }
  391.  
  392.         if (function_exists('ibase_timefmt')) {
  393.             @ibase_timefmt("%Y-%m-%d %H:%M:%S"IBASE_TIMESTAMP);
  394.             @ibase_timefmt("%Y-%m-%d"IBASE_DATE);
  395.         else {
  396.             @ini_set("ibase.timestampformat""%Y-%m-%d %H:%M:%S");
  397.             //@ini_set("ibase.timeformat", "%H:%M:%S");
  398.             @ini_set("ibase.dateformat""%Y-%m-%d");
  399.         }
  400.  
  401.         return $connection;
  402.     }
  403.  
  404.     // }}}
  405.     // {{{ connect()
  406.  
  407.     /**
  408.      * Connect to the database
  409.      *
  410.      * @return true on success, MDB2 Error Object on failure
  411.      * @access public
  412.      */
  413.     function connect()
  414.     {
  415.         $database_file $this->_getDatabaseFile($this->database_name);
  416.         if (is_resource($this->connection)) {
  417.             if (count(array_diff($this->connected_dsn$this->dsn)) == 0
  418.                 && $this->connected_database_name == $database_file
  419.                 && $this->opened_persistent == $this->options['persistent']
  420.             {
  421.                 return MDB2_OK;
  422.             }
  423.             $this->disconnect(false);
  424.         }
  425.  
  426.         if (!PEAR::loadExtension('interbase')) {
  427.             return $this->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  428.                 'connect: extension '.$this->phptype.' is not compiled into PHP');
  429.         }
  430.  
  431.         if (!empty($this->database_name)) {
  432.             $connection $this->_doConnect($database_file$this->options['persistent']);
  433.             if (PEAR::isError($connection)) {
  434.                 return $connection;
  435.             }
  436.             $this->connection =$connection;
  437.             $this->connected_dsn $this->dsn;
  438.             $this->connected_database_name $database_file;
  439.             $this->opened_persistent $this->options['persistent'];
  440.             $this->dbsyntax $this->dsn['dbsyntax'$this->dsn['dbsyntax'$this->phptype;
  441.             $this->supported['limit_queries'($this->dbsyntax == 'firebird'? true : 'emulated';
  442.         }
  443.         return MDB2_OK;
  444.     }
  445.  
  446.     // }}}
  447.     // {{{ disconnect()
  448.  
  449.     /**
  450.      * Log out and disconnect from the database.
  451.      *
  452.      * @param  boolean $force if the disconnect should be forced even if the
  453.      *                         connection is opened persistently
  454.      * @return mixed true on success, false if not connected and error
  455.      *                 object on error
  456.      * @access public
  457.      */
  458.     function disconnect($force = true)
  459.     {
  460.         if (is_resource($this->connection)) {
  461.             if ($this->in_transaction{
  462.                 $this->rollback();
  463.             }
  464.             if (!$this->opened_persistent || $force{
  465.                 @ibase_close($this->connection);
  466.             }
  467.         }
  468.         return parent::disconnect($force);
  469.     }
  470.  
  471.     // }}}
  472.     // {{{ _doQuery()
  473.  
  474.     /**
  475.      * Execute a query
  476.      * @param string $query  query
  477.      * @param boolean $is_manip  if the query is a manipulation query
  478.      * @param resource $connection 
  479.      * @param string $database_name 
  480.      * @return result or error object
  481.      * @access protected
  482.      */
  483.     function &_doQuery($query$is_manip = false$connection = null$database_name = null)
  484.     {
  485.         $this->last_query $query;
  486.         $this->debug($query'query'$is_manip);
  487.         if ($this->getOption('disable_query')) {
  488.             if ($is_manip{
  489.                 return 0;
  490.             }
  491.             return null;
  492.         }
  493.  
  494.         if (is_null($connection)) {
  495.             $connection $this->getConnection();
  496.             if (PEAR::isError($connection)) {
  497.                 return $connection;
  498.             }
  499.         }
  500.         $result @ibase_query($connection$query);
  501.  
  502.         if ($result === false{
  503.             $err $this->raiseError(nullnullnull,
  504.                 '_doQuery: Could not execute statement');
  505.             return $err;
  506.         }
  507.  
  508.         return $result;
  509.     }
  510.  
  511.     // }}}
  512.     // {{{ _affectedRows()
  513.  
  514.     /**
  515.      * Returns the number of rows affected
  516.      *
  517.      * @param resource $result 
  518.      * @param resource $connection 
  519.      * @return mixed MDB2 Error Object or the number of rows affected
  520.      * @access private
  521.      */
  522.     function _affectedRows($connection$result = null)
  523.     {
  524.         if (is_null($connection)) {
  525.             $connection $this->getConnection();
  526.             if (PEAR::isError($connection)) {
  527.                 return $connection;
  528.             }
  529.         }
  530.         return (function_exists('ibase_affected_rows'@ibase_affected_rows($connection: 0);
  531.     }
  532.  
  533.     // }}}
  534.     // {{{ _modifyQuery()
  535.  
  536.     /**
  537.      * Changes a query string for various DBMS specific reasons
  538.      *
  539.      * @param string $query  query to modify
  540.      * @param boolean $is_manip  if it is a DML query
  541.      * @param integer $limit  limit the number of rows
  542.      * @param integer $offset  start reading from given offset
  543.      * @return string modified query
  544.      * @access protected
  545.      */
  546.     function _modifyQuery($query$is_manip$limit$offset)
  547.     {
  548.         if ($limit > 0 && $this->supports('limit_queries'=== true{
  549.             $query preg_replace('/^([\s(])*SELECT(?!\s*FIRST\s*\d+)/i',
  550.                 "SELECT FIRST $limit SKIP $offset"$query);
  551.         }
  552.         return $query;
  553.     }
  554.  
  555.     // }}}
  556.     // {{{ getServerVersion()
  557.  
  558.     /**
  559.      * return version information about the server
  560.      *
  561.      * @param string     $native  determines if the raw version string should be returned
  562.      * @return mixed array/string with version information or MDB2 error object
  563.      * @access public
  564.      */
  565.     function getServerVersion($native = false)
  566.     {
  567.         $server_info = false;
  568.         if ($this->connected_server_info{
  569.             $server_info $this->connected_server_info;
  570.         elseif ($this->options['server_version']{
  571.             $server_info $this->options['server_version'];
  572.         elseif ($this->options['DBA_username']{
  573.             $ibserv @ibase_service_attach($this->dsn['hostspec']$this->options['DBA_username']$this->options['DBA_password']);
  574.             $server_info @ibase_server_info($ibservIBASE_SVC_SERVER_VERSION);
  575.             @ibase_service_detach($ibserv);
  576.         }
  577.         if (!$server_info{
  578.             return $this->raiseError(MDB2_ERROR_UNSUPPORTEDnullnull,
  579.                 'getServerVersion: Requires either "server_version" or "DBA_username"/"DBA_password" option');
  580.         }
  581.         // cache server_info
  582.         $this->connected_server_info $server_info;
  583.         if (!$native{
  584.             //WI-V1.5.3.4854 Firebird 1.5
  585.             if (!preg_match('/-V([\d\.]*)/'$server_info$matches)) {
  586.                 return $this->raiseError(MDB2_ERROR_INVALIDnullnull,
  587.                     'getServerVersion: Could not parse version information:'.$server_info);
  588.             }
  589.             $tmp explode('.'$matches[1]4);
  590.             $server_info = array(
  591.                 'major' => isset($tmp[0]$tmp[0: null,
  592.                 'minor' => isset($tmp[1]$tmp[1: null,
  593.                 'patch' => isset($tmp[2]$tmp[2: null,
  594.                 'extra' => isset($tmp[3]$tmp[3: null,
  595.                 'native' => $server_info,
  596.             );
  597.         }
  598.         return $server_info;
  599.     }
  600.  
  601.     // }}}
  602.     // {{{ prepare()
  603.  
  604.     /**
  605.      * Prepares a query for multiple execution with execute().
  606.      * With some database backends, this is emulated.
  607.      * prepare() requires a generic query as string like
  608.      * 'INSERT INTO numbers VALUES(?,?)' or
  609.      * 'INSERT INTO numbers VALUES(:foo,:bar)'.
  610.      * The ? and :[a-zA-Z] and  are placeholders which can be set using
  611.      * bindParam() and the query can be send off using the execute() method.
  612.      *
  613.      * @param string $query the query to prepare
  614.      * @param mixed   $types  array that contains the types of the placeholders
  615.      * @param mixed   $result_types  array that contains the types of the columns in
  616.      *                         the result set or MDB2_PREPARE_RESULT, if set to
  617.      *                         MDB2_PREPARE_MANIP the query is handled as a manipulation query
  618.      * @param mixed   $lobs   key (field) value (parameter) pair for all lob placeholders
  619.      * @return mixed resource handle for the prepared query on success, a MDB2
  620.      *         error on failure
  621.      * @access public
  622.      * @see bindParam, execute
  623.      */
  624.     function &prepare($query$types = null$result_types = null$lobs = array())
  625.     {
  626.         $is_manip ($result_types === MDB2_PREPARE_MANIP);
  627.         $offset $this->offset;
  628.         $limit $this->limit;
  629.         $this->offset $this->limit = 0;
  630.         $this->debug($query'prepare'$is_manip);
  631.         $placeholder_type_guess $placeholder_type = null;
  632.         $question '?';
  633.         $colon ':';
  634.         $positions = array();
  635.         $position = 0;
  636.         while ($position strlen($query)) {
  637.             $q_position strpos($query$question$position);
  638.             $c_position strpos($query$colon$position);
  639.             if ($q_position && $c_position{
  640.                 $p_position min($q_position$c_position);
  641.             elseif ($q_position{
  642.                 $p_position $q_position;
  643.             elseif ($c_position{
  644.                 $p_position $c_position;
  645.             else {
  646.                 break;
  647.             }
  648.             if (is_null($placeholder_type)) {
  649.                 $placeholder_type_guess $query[$p_position];
  650.             }
  651.             if (is_int($quote strpos($query"'"$position)) && $quote $p_position{
  652.                 if (!is_int($end_quote strpos($query"'"$quote + 1))) {
  653.                     $err =$this->raiseError(MDB2_ERROR_SYNTAXnullnull,
  654.                         'prepare: query with an unterminated text string specified');
  655.                     return $err;
  656.                 }
  657.                 switch ($this->escape_quotes{
  658.                 case '':
  659.                 case "'":
  660.                     $position $end_quote + 1;
  661.                     break;
  662.                 default:
  663.                     if ($end_quote == $quote + 1{
  664.                         $position $end_quote + 1;
  665.                     else {
  666.                         if ($query[$end_quote-1== $this->escape_quotes{
  667.                             $position $end_quote;
  668.                         else {
  669.                             $position $end_quote + 1;
  670.                         }
  671.                     }
  672.                     break;
  673.                 }
  674.             elseif ($query[$position== $placeholder_type_guess{
  675.                 if (is_null($placeholder_type)) {
  676.                     $placeholder_type $query[$p_position];
  677.                     $question $colon $placeholder_type;
  678.                 }
  679.                 if ($placeholder_type == ':'{
  680.                     $parameter preg_replace('/^.{'.($position+1).'}([a-z0-9_]+).*$/si''\\1'$query);
  681.                     if ($parameter === ''{
  682.                         $err =$this->raiseError(MDB2_ERROR_SYNTAXnullnull,
  683.                             'prepare: named parameter with an empty name');
  684.                         return $err;
  685.                     }
  686.                     $positions[$parameter$p_position;
  687.                     $query substr_replace($query'?'$positionstrlen($parameter)+1);
  688.                 else {
  689.                     $positions[$p_position;
  690.                 }
  691.                 $position $p_position + 1;
  692.             else {
  693.                 $position $p_position;
  694.             }
  695.         }
  696.         $connection $this->getConnection();
  697.         if (PEAR::isError($connection)) {
  698.             return $connection;
  699.         }
  700.         $statement @ibase_prepare($connection$query);
  701.         if (!$statement{
  702.             $err =$this->raiseError(nullnullnull,
  703.                 'Could not create statement');
  704.             return $err;
  705.         }
  706.  
  707.         $class_name 'MDB2_Statement_'.$this->phptype;
  708.         $obj =new $class_name($this$statement$positions$query$types$result_types$is_manip$limit$offset);
  709.         return $obj;
  710.     }
  711.  
  712.     // }}}
  713.     // {{{ getSequenceName()
  714.  
  715.     /**
  716.      * adds sequence name formatting to a sequence name
  717.      *
  718.      * @param string $sqn name of the sequence
  719.      * @return string formatted sequence name
  720.      * @access public
  721.      */
  722.     function getSequenceName($sqn)
  723.     {
  724.         return strtoupper(parent::getSequenceName($sqn));
  725.     }
  726.  
  727.     // }}}
  728.     // {{{ nextID()
  729.  
  730.     /**
  731.      * Returns the next free id of a sequence
  732.      *
  733.      * @param string $seq_name name of the sequence
  734.      * @param boolean $ondemand when true the sequence is
  735.      *                           automatic created, if it
  736.      *                           not exists
  737.      * @return mixed MDB2 Error Object or id
  738.      * @access public
  739.      */
  740.     function nextID($seq_name$ondemand = true)
  741.     {
  742.         $sequence_name $this->getSequenceName($seq_name);
  743.         $query 'SELECT GEN_ID('.$sequence_name.', 1) as the_value FROM RDB$DATABASE';
  744.         $this->expectError('*');
  745.         $result $this->queryOne($query'integer');
  746.         $this->popExpect();
  747.         if (PEAR::isError($result)) {
  748.             if ($ondemand{
  749.                 $this->loadModule('Manager'nulltrue);
  750.                 // Since we are creating the sequence on demand
  751.                 // we know the first id = 1 so initialize the
  752.                 // sequence at 2
  753.                 $result $this->manager->createSequence($seq_name2);
  754.                 if (PEAR::isError($result)) {
  755.                     return $this->raiseError($resultnullnull,
  756.                         'nextID: on demand sequence could not be created');
  757.                 else {
  758.                     // First ID of a newly created sequence is 1
  759.                     // return 1;
  760.                     // BUT generators are not always reset, so return the actual value
  761.                     return $this->currID($seq_name);
  762.                 }
  763.             }
  764.         }
  765.         return $result;
  766.     }
  767.  
  768.     // }}}
  769.     // {{{ currID()
  770.  
  771.     /**
  772.      * Returns the current id of a sequence
  773.      *
  774.      * @param string $seq_name name of the sequence
  775.      * @return mixed MDB2 Error Object or id
  776.      * @access public
  777.      */
  778.     function currID($seq_name)
  779.     {
  780.         $sequence_name $this->getSequenceName($seq_name);
  781.         $query 'SELECT GEN_ID('.$sequence_name.', 0) as the_value FROM RDB$DATABASE';
  782.         $value $this->queryOne($query);
  783.         if (PEAR::isError($value)) {
  784.             return $this->raiseError($resultnullnull,
  785.                 'currID: Unable to select from ' $seq_name;
  786.         }
  787.         if (!is_numeric($value)) {
  788.             return $this->raiseError(MDB2_ERRORnullnull,
  789.                 'currID: could not find value in sequence table');
  790.         }
  791.         return $value;
  792.     }
  793.  
  794.     // }}}
  795. }
  796.  
  797. /**
  798.  * MDB2 FireBird/InterBase result driver
  799.  *
  800.  * @package MDB2
  801.  * @category Database
  802.  * @author  Lorenzo Alberton <l.alberton@quipo.it>
  803.  */
  804. class MDB2_Result_ibase extends MDB2_Result_Common
  805. {
  806.     // {{{ _skipLimitOffset()
  807.  
  808.     /**
  809.      * Skip the first row of a result set.
  810.      *
  811.      * @param resource $result 
  812.      * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  813.      * @access protected
  814.      */
  815.     function _skipLimitOffset()
  816.     {
  817.         if ($this->db->supports('limit_queries'=== true{
  818.             return true;
  819.         }
  820.         if ($this->limit{
  821.             if ($this->rownum $this->limit{
  822.                 return false;
  823.             }
  824.         }
  825.         if ($this->offset{
  826.             while ($this->offset_count $this->offset{
  827.                 ++$this->offset_count;
  828.                 if (!is_array(@ibase_fetch_row($this->result))) {
  829.                     $this->offset_count $this->offset;
  830.                     return false;
  831.                 }
  832.             }
  833.         }
  834.         return true;
  835.     }
  836.  
  837.     // }}}
  838.     // {{{ fetchRow()
  839.  
  840.     /**
  841.      * Fetch a row and insert the data into an existing array.
  842.      *
  843.      * @param int  $fetchmode how the array data should be indexed
  844.      * @param int  $rownum    number of the row where the data can be found
  845.      * @return int data array on success, a MDB2 error on failure
  846.      * @access public
  847.      */
  848.     function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT$rownum = null)
  849.     {
  850.         if ($this->result === true{
  851.             //query successfully executed, but without results...
  852.             $null = null;
  853.             return $null;
  854.         }
  855.         if (!$this->_skipLimitOffset()) {
  856.             $null = null;
  857.             return $null;
  858.         }
  859.         if (!is_null($rownum)) {
  860.             $seek $this->seek($rownum);
  861.             if (PEAR::isError($seek)) {
  862.                 return $seek;
  863.             }
  864.         }
  865.         if ($fetchmode == MDB2_FETCHMODE_DEFAULT{
  866.             $fetchmode $this->db->fetchmode;
  867.         }
  868.         if ($fetchmode MDB2_FETCHMODE_ASSOC{
  869.             $row @ibase_fetch_assoc($this->result);
  870.             if (is_array($row)
  871.                 && $this->db->options['portability'MDB2_PORTABILITY_FIX_CASE
  872.             {
  873.                 $row array_change_key_case($row$this->db->options['field_case']);
  874.             }
  875.         else {
  876.             $row @ibase_fetch_row($this->result);
  877.         }
  878.         if (!$row{
  879.             if ($this->result === false{
  880.                 $err =$this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  881.                     'fetchRow: resultset has already been freed');
  882.                 return $err;
  883.             }
  884.             $null = null;
  885.             return $null;
  886.         }
  887.         if (($mode ($this->db->options['portability'MDB2_PORTABILITY_RTRIM)
  888.             + ($this->db->options['portability'MDB2_PORTABILITY_EMPTY_TO_NULL))
  889.         {
  890.             $this->db->_fixResultArrayValues($row$mode);
  891.         }
  892.         if (!empty($this->values)) {
  893.             $this->_assignBindColumns($row);
  894.         }
  895.         if (!empty($this->types)) {
  896.             $row $this->db->datatype->convertResultRow($this->types$row);
  897.         }
  898.         if ($fetchmode === MDB2_FETCHMODE_OBJECT{
  899.             $object_class $this->db->options['fetch_class'];
  900.             if ($object_class == 'stdClass'{
  901.                 $row = (object) $row;
  902.             else {
  903.                 $row &new $object_class($row);
  904.             }
  905.         }
  906.         ++$this->rownum;
  907.         return $row;
  908.     }
  909.  
  910.     // }}}
  911.     // {{{ _getColumnNames()
  912.  
  913.     /**
  914.      * Retrieve the names of columns returned by the DBMS in a query result.
  915.      *
  916.      * @return mixed associative array variable
  917.      *       that holds the names of columns. The indexes of the array are
  918.      *       the column names mapped to lower case and the values are the
  919.      *       respective numbers of the columns starting from 0. Some DBMS may
  920.      *       not return any columns when the result set does not contain any
  921.      *       rows.
  922.      * @access private
  923.      */
  924.     function _getColumnNames()
  925.     {
  926.         $columns = array();
  927.         $numcols $this->numCols();
  928.         if (PEAR::isError($numcols)) {
  929.             return $numcols;
  930.         }
  931.         for ($column = 0; $column $numcols$column++{
  932.             $column_info @ibase_field_info($this->result$column);
  933.             $columns[$column_info['alias']] $column;
  934.         }
  935.         if ($this->db->options['portability'MDB2_PORTABILITY_FIX_CASE{
  936.             $columns array_change_key_case($columns$this->db->options['field_case']);
  937.         }
  938.         return $columns;
  939.     }
  940.  
  941.     // }}}
  942.     // {{{ numCols()
  943.  
  944.     /**
  945.      * Count the number of columns returned by the DBMS in a query result.
  946.      *
  947.      * @return mixed integer value with the number of columns, a MDB2 error
  948.      *       on failure
  949.      * @access public
  950.      */
  951.     function numCols()
  952.     {
  953.         if ($this->result === true{
  954.             //query successfully executed, but without results...
  955.             return 0;
  956.         }
  957.  
  958.         if (!is_resource($this->result)) {
  959.             return $this->db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  960.                 'numCols(): not a valid ibase resource');
  961.         }
  962.         $cols @ibase_num_fields($this->result);
  963.         if (is_null($cols)) {
  964.             if ($this->result === false{
  965.                 return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  966.                     'numCols: resultset has already been freed');
  967.             elseif (is_null($this->result)) {
  968.                 return count($this->types);
  969.             }
  970.             return $this->db->raiseError(nullnullnull,
  971.                 'numCols: Could not get column count');
  972.         }
  973.         return $cols;
  974.     }
  975.  
  976.     // }}}
  977.     // {{{ free()
  978.  
  979.     /**
  980.      * Free the internal resources associated with $result.
  981.      *
  982.      * @return boolean true on success, false if $result is invalid
  983.      * @access public
  984.      */
  985.     function free()
  986.     {
  987.         if (is_resource($this->result)) {
  988.             $free @ibase_free_result($this->result);
  989.             if (!$free{
  990.                 if (!$this->result{
  991.                     return MDB2_OK;
  992.                 }
  993.                 return $this->db->raiseError(nullnullnull,
  994.                     'numCols: Could not free result');
  995.             }
  996.         }
  997.         $this->result = false;
  998.         return MDB2_OK;
  999.     }
  1000.  
  1001.     // }}}
  1002. }
  1003.  
  1004. /**
  1005.  * MDB2 FireBird/InterBase buffered result driver
  1006.  *
  1007.  * @package MDB2
  1008.  * @category Database
  1009.  * @author  Lorenzo Alberton <l.alberton@quipo.it>
  1010.  */
  1011. {
  1012.     // {{{ class vars
  1013.  
  1014.     var $buffer;
  1015.     var $buffer_rownum = - 1;
  1016.  
  1017.     // }}}
  1018.     // {{{ _fillBuffer()
  1019.  
  1020.     /**
  1021.      * Fill the row buffer
  1022.      *
  1023.      * @param int $rownum   row number upto which the buffer should be filled
  1024.      *                       if the row number is null all rows are ready into the buffer
  1025.      * @return boolean true on success, false on failure
  1026.      * @access protected
  1027.      */
  1028.     function _fillBuffer($rownum = null)
  1029.     {
  1030.         if (isset($this->buffer&& is_array($this->buffer)) {
  1031.             if (is_null($rownum)) {
  1032.                 if (!end($this->buffer)) {
  1033.                     return false;
  1034.                 }
  1035.             elseif (isset($this->buffer[$rownum])) {
  1036.                 return (bool) $this->buffer[$rownum];
  1037.             }
  1038.         }
  1039.  
  1040.         if (!$this->_skipLimitOffset()) {
  1041.             return false;
  1042.         }
  1043.  
  1044.         $buffer = true;
  1045.         while ((is_null($rownum|| $this->buffer_rownum < $rownum)
  1046.             && (!$this->limit || $this->buffer_rownum < $this->limit)
  1047.             && ($buffer @ibase_fetch_row($this->result))
  1048.         {
  1049.             ++$this->buffer_rownum;
  1050.             $this->buffer[$this->buffer_rownum$buffer;
  1051.         }
  1052.  
  1053.         if (!$buffer{
  1054.             ++$this->buffer_rownum;
  1055.             $this->buffer[$this->buffer_rownum= false;
  1056.             return false;
  1057.         elseif ($this->limit && $this->buffer_rownum >= $this->limit{
  1058.             ++$this->buffer_rownum;
  1059.             $this->buffer[$this->buffer_rownum= false;
  1060.         }
  1061.         return true;
  1062.     }
  1063.  
  1064.     // }}}
  1065.     // {{{ fetchRow()
  1066.  
  1067.     /**
  1068.      * Fetch a row and insert the data into an existing array.
  1069.      *
  1070.      * @param int       $fetchmode  how the array data should be indexed
  1071.      * @param int    $rownum    number of the row where the data can be found
  1072.      * @return int data array on success, a MDB2 error on failure
  1073.      * @access public
  1074.      */
  1075.     function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT$rownum = null)
  1076.     {
  1077.         if ($this->result === true || is_null($this->result)) {
  1078.             //query successfully executed, but without results...
  1079.             $null = null;
  1080.             return $null;
  1081.         }
  1082.         if ($this->result === false{
  1083.             $err =$this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1084.                 'fetchRow: resultset has already been freed');
  1085.             return $err;
  1086.         }
  1087.         if (!is_null($rownum)) {
  1088.             $seek $this->seek($rownum);
  1089.             if (PEAR::isError($seek)) {
  1090.                 return $seek;
  1091.             }
  1092.         }
  1093.         $target_rownum $this->rownum + 1;
  1094.         if ($fetchmode == MDB2_FETCHMODE_DEFAULT{
  1095.             $fetchmode $this->db->fetchmode;
  1096.         }
  1097.         if (!$this->_fillBuffer($target_rownum)) {
  1098.             $null = null;
  1099.             return $null;
  1100.         }
  1101.         $row $this->buffer[$target_rownum];
  1102.         if ($fetchmode MDB2_FETCHMODE_ASSOC{
  1103.             $column_names $this->getColumnNames();
  1104.             foreach ($column_names as $name => $i{
  1105.                 $column_names[$name$row[$i];
  1106.             }
  1107.             $row $column_names;
  1108.         }
  1109.         if (($mode ($this->db->options['portability'MDB2_PORTABILITY_RTRIM)
  1110.             + ($this->db->options['portability'MDB2_PORTABILITY_EMPTY_TO_NULL))
  1111.         {
  1112.             $this->db->_fixResultArrayValues($row$mode);
  1113.         }
  1114.         if (!empty($this->values)) {
  1115.             $this->_assignBindColumns($row);
  1116.         }
  1117.         if (!empty($this->types)) {
  1118.             $row $this->db->datatype->convertResultRow($this->types$row);
  1119.         }
  1120.         if ($fetchmode === MDB2_FETCHMODE_OBJECT{
  1121.             $object_class $this->db->options['fetch_class'];
  1122.             if ($object_class == 'stdClass'{
  1123.                 $row = (object) $row;
  1124.             else {
  1125.                 $row &new $object_class($row);
  1126.             }
  1127.         }
  1128.         ++$this->rownum;
  1129.         return $row;
  1130.     }
  1131.  
  1132.     // }}}
  1133.     // {{{ seek()
  1134.  
  1135.     /**
  1136.      * Seek to a specific row in a result set
  1137.      *
  1138.      * @param int    $rownum    number of the row where the data can be found
  1139.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  1140.      * @access public
  1141.      */
  1142.     function seek($rownum = 0)
  1143.     {
  1144.         if ($this->result === false{
  1145.             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1146.                 'seek: resultset has already been freed');
  1147.         }
  1148.         $this->rownum $rownum - 1;
  1149.         return MDB2_OK;
  1150.     }
  1151.  
  1152.     // }}}
  1153.     // {{{ valid()
  1154.  
  1155.     /**
  1156.      * Check if the end of the result set has been reached
  1157.      *
  1158.      * @return mixed true or false on sucess, a MDB2 error on failure
  1159.      * @access public
  1160.      */
  1161.     function valid()
  1162.     {
  1163.         if ($this->result === false{
  1164.             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1165.                 'valid: resultset has already been freed');
  1166.         elseif (is_null($this->result)) {
  1167.             return true;
  1168.         }
  1169.         if ($this->_fillBuffer($this->rownum + 1)) {
  1170.             return true;
  1171.         }
  1172.         return false;
  1173.     }
  1174.  
  1175.     // }}}
  1176.     // {{{ numRows()
  1177.  
  1178.     /**
  1179.      * Returns the number of rows in a result object
  1180.      *
  1181.      * @return mixed MDB2 Error Object or the number of rows
  1182.      * @access public
  1183.      */
  1184.     function numRows()
  1185.     {
  1186.         if ($this->result === false{
  1187.             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  1188.                 'numRows: resultset has already been freed');
  1189.         elseif (is_null($this->result)) {
  1190.             return 0;
  1191.         }
  1192.         $this->_fillBuffer();
  1193.         return $this->buffer_rownum;
  1194.     }
  1195.  
  1196.     // }}}
  1197.     // {{{ free()
  1198.  
  1199.     /**
  1200.      * Free the internal resources associated with $result.
  1201.      *
  1202.      * @return boolean true on success, false if $result is invalid
  1203.      * @access public
  1204.      */
  1205.     function free()
  1206.     {
  1207.         $this->buffer = null;
  1208.         $this->buffer_rownum = null;
  1209.         $free = parent::free();
  1210.     }
  1211.  
  1212.     // }}}
  1213. }
  1214.  
  1215. /**
  1216.  * MDB2 FireBird/InterBase statement driver
  1217.  *
  1218.  * @package MDB2
  1219.  * @category Database
  1220.  * @author  Lorenzo Alberton <l.alberton@quipo.it>
  1221.  */
  1222. class MDB2_Statement_ibase extends MDB2_Statement_Common
  1223. {
  1224.     // {{{ _execute()
  1225.  
  1226.     /**
  1227.      * Execute a prepared query statement helper method.
  1228.      *
  1229.      * @param mixed $result_class string which specifies which result class to use
  1230.      * @param mixed $result_wrap_class string which specifies which class to wrap results in
  1231.      * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  1232.      * @access private
  1233.      */
  1234.     function &_execute($result_class = true$result_wrap_class = false)
  1235.     {
  1236.         $this->db->last_query = $this->query;
  1237.         $this->db->debug($this->query'execute'$this->is_manip);
  1238.         $this->db->debug($this->values'parameters'$this->is_manip);
  1239.         if ($this->db->getOption('disable_query')) {
  1240.             if ($this->is_manip{
  1241.                 $return = 0;
  1242.                 return $return;
  1243.             }
  1244.             $null = null;
  1245.             return $null;
  1246.         }
  1247.  
  1248.         $connection $this->db->getConnection();
  1249.         if (PEAR::isError($connection)) {
  1250.             return $connection;
  1251.         }
  1252.  
  1253.         $parameters = array(0 => $this->statement);
  1254.         foreach ($this->positions as $parameter => $current_position{
  1255.             if (!array_key_exists($parameter$this->values)) {
  1256.                 return $this->db->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  1257.                     '_execute: Unable to bind to missing placeholder: '.$parameter);
  1258.             }
  1259.             $value $this->values[$parameter];
  1260.             $type array_key_exists($parameter$this->types$this->types[$parameter: null;
  1261.             $parameters[$this->db->quote($value$typefalse);
  1262.         }
  1263.  
  1264.         $result @call_user_func_array('ibase_execute'$parameters);
  1265.         if ($result === false{
  1266.             $err =$this->db->raiseError(nullnullnull,
  1267.                 '_execute: Could not execute statement');
  1268.             return $err;
  1269.         }
  1270.  
  1271.         if ($this->is_manip{
  1272.             $affected_rows $this->db->_affectedRows($connection);
  1273.             return $affected_rows;
  1274.         }
  1275.  
  1276.         $result =$this->db->_wrapResult($result$this->result_types,
  1277.             $result_class$result_wrap_class$this->limit$this->offset);
  1278.         return $result;
  1279.     }
  1280.  
  1281.     // }}}
  1282.  
  1283.     // }}}
  1284.     // {{{ free()
  1285.  
  1286.     /**
  1287.      * Release resources allocated for the specified prepared query.
  1288.      *
  1289.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  1290.      * @access public
  1291.      */
  1292.     function free()
  1293.     {
  1294.         if (!@ibase_free_query($this->statement)) {
  1295.             return $this->db->raiseError(nullnullnull,
  1296.                 'free: Could not free statement');
  1297.         }
  1298.         return MDB2_OK;
  1299.     }
  1300. }
  1301. ?>

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