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

Source for file fbsql.php

Documentation is available at fbsql.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-2004 Manuel Lemos, Tomas V.V.Cox,                 |
  7. // | Stig. S. Bakken, Lukas Smith, Frank M. Kromann                       |
  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@backendmedia.com>                         |
  44. // +----------------------------------------------------------------------+
  45. //
  46. // $Id: fbsql.php,v 1.61 2005/04/25 13:09:03 lsmith Exp $
  47. //
  48.  
  49. /**
  50.  * MDB2 FrontBase driver
  51.  *
  52.  * @package MDB2
  53.  * @category Database
  54.  * @author  Lukas Smith <smith@backendmedia.com>
  55.  * @author  Frank M. Kromann <frank@kromann.info>
  56.  */
  57. {
  58.     // {{{ properties
  59.     var $escape_quotes = "'";
  60.  
  61.     var $max_text_length = 32768;
  62.  
  63.     // }}}
  64.     // {{{ constructor
  65.  
  66.     /**
  67.     * Constructor
  68.     */
  69.     function __construct()
  70.     {
  71.         parent::__construct();
  72.  
  73.         $this->phptype = 'fbsql';
  74.         $this->dbsyntax = 'fbsql';
  75.  
  76.         $this->supported['sequences'= true;
  77.         $this->supported['indexes'= true;
  78.         $this->supported['affected_rows'= true;
  79.         $this->supported['transactions'= true;
  80.         $this->supported['summary_functions'= true;
  81.         $this->supported['order_by_text'= true;
  82.         $this->supported['current_id'= false;
  83.         $this->supported['limit_queries'= true;
  84.         $this->supported['LOBs'= true;
  85.         $this->supported['replace'= true;
  86.         $this->supported['sub_selects'= true;
  87.         $this->supported['auto_increment'= true;
  88.     }
  89.  
  90.     // }}}
  91.     // {{{ errorInfo()
  92.  
  93.     /**
  94.      * This method is used to collect information about an error
  95.      *
  96.      * @param integer $error 
  97.      * @return array 
  98.      * @access public
  99.      */
  100.     function errorInfo($error = null)
  101.     {
  102.        if ($this->connection{
  103.            $native_code @fbsql_errno($this->connection);
  104.            $native_msg  @fbsql_error($this->connection);
  105.        else {
  106.            $native_code @fbsql_errno();
  107.            $native_msg  @fbsql_error();
  108.        }
  109.         if (is_null($error)) {
  110.             static $ecode_map;
  111.             if (empty($ecode_map)) {
  112.                 $ecode_map = array(
  113.                      22 => MDB2_ERROR_SYNTAX,
  114.                      85 => MDB2_ERROR_ALREADY_EXISTS,
  115.                     108 => MDB2_ERROR_SYNTAX,
  116.                     116 => MDB2_ERROR_NOSUCHTABLE,
  117.                     124 => MDB2_ERROR_VALUE_COUNT_ON_ROW,
  118.                     215 => MDB2_ERROR_NOSUCHFIELD,
  119.                     217 => MDB2_ERROR_INVALID_NUMBER,
  120.                     226 => MDB2_ERROR_NOSUCHFIELD,
  121.                     231 => MDB2_ERROR_INVALID,
  122.                     239 => MDB2_ERROR_TRUNCATED,
  123.                     251 => MDB2_ERROR_SYNTAX,
  124.                     266 => MDB2_ERROR_NOT_FOUND,
  125.                     357 => MDB2_ERROR_CONSTRAINT_NOT_NULL,
  126.                     358 => MDB2_ERROR_CONSTRAINT,
  127.                     360 => MDB2_ERROR_CONSTRAINT,
  128.                     361 => MDB2_ERROR_CONSTRAINT,
  129.                 );
  130.             }
  131.             if (isset($ecode_map[$native_code])) {
  132.                 $error $ecode_map[$native_code];
  133.             }
  134.         }
  135.         return array($error$native_code$native_msg);
  136.     }
  137.  
  138.     // }}}
  139.     // {{{ beginTransaction()
  140.  
  141.     /**
  142.      * Start a transaction.
  143.      *
  144.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  145.      * @access public
  146.      */
  147.     function beginTransaction()
  148.     {
  149.         $this->debug('starting transaction''beginTransaction');
  150.         if ($this->in_transaction{
  151.             return MDB2_OK;  //nothing to do
  152.         }
  153.         if (!$this->destructor_registered && $this->opened_persistent{
  154.             $this->destructor_registered = true;
  155.             register_shutdown_function('MDB2_closeOpenTransactions');
  156.         }
  157.         $result $this->_doQuery('SET COMMIT FALSE;'true);
  158.         if (PEAR::isError($result)) {
  159.             return $result;
  160.         }
  161.         $this->in_transaction = true;
  162.         return MDB2_OK;
  163.     }
  164.  
  165.     // }}}
  166.     // {{{ commit()
  167.  
  168.     /**
  169.      * Commit the database changes done during a transaction that is in
  170.      * progress.
  171.      *
  172.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  173.      * @access public
  174.      */
  175.     function commit()
  176.     {
  177.         $this->debug('commit transaction''commit');
  178.         if (!$this->in_transaction{
  179.             return $this->raiseError(MDB2_ERRORnullnull,
  180.                 'commit: transaction changes are being auto commited');
  181.         }
  182.         $result $this->_doQuery('COMMIT;'true);
  183.         if (PEAR::isError($result)) {
  184.             return $result;
  185.         }
  186.         $result $this->_doQuery('SET COMMIT TRUE;'true);
  187.         if (PEAR::isError($result)) {
  188.             return $result;
  189.         }
  190.         $this->in_transaction = false;
  191.         return MDB2_OK;
  192.     }
  193.  
  194.     // }}}
  195.     // {{{ rollback()
  196.  
  197.     /**
  198.      * Cancel any database changes done during a transaction that is in
  199.      * progress.
  200.      *
  201.      * @return mixed MDB2_OK on success, a MDB2 error on failure
  202.      * @access public
  203.      */
  204.     function rollback()
  205.     {
  206.         $this->debug('rolling back transaction''rollback');
  207.         if (!$this->in_transaction{
  208.             return $this->raiseError(MDB2_ERRORnullnull,
  209.                 'rollback: transactions can not be rolled back when changes are auto committed');
  210.         }
  211.         $result $this->_doQuery('ROLLBACK;'true);
  212.         if (PEAR::isError($result)) {
  213.             return $result;
  214.         }
  215.         $result $this->_doQuery('SET COMMIT TRUE;'true);
  216.         if (PEAR::isError($result)) {
  217.             return $result;
  218.         }
  219.         $this->in_transaction = false;
  220.         return MDB2_OK;
  221.     }
  222.  
  223.     // }}}
  224.     // {{{ connect()
  225.  
  226.     /**
  227.      * Connect to the database
  228.      *
  229.      * @return true on success, MDB2 Error Object on failure
  230.      ***/
  231.     function connect()
  232.     {
  233.         if (is_resource($this->connection)) {
  234.             if (count(array_diff($this->connected_dsn$this->dsn)) == 0
  235.                 && $this->opened_persistent == $this->options['persistent']
  236.             {
  237.                 return MDB2_OK;
  238.             }
  239.             $this->disconnect(false);
  240.         }
  241.  
  242.         if (!PEAR::loadExtension($this->phptype)) {
  243.             return $this->raiseError(MDB2_ERROR_NOT_FOUNDnullnull,
  244.                 'connect: extension '.$this->phptype.' is not compiled into PHP');
  245.         }
  246.  
  247.         $params = array(
  248.             $this->dsn['hostspec'$this->dsn['hostspec''localhost',
  249.             $this->dsn['username'$this->dsn['username': null,
  250.             $this->dsn['password'$this->dsn['password': null,
  251.         );
  252.  
  253.         $connect_function $this->options['persistent''fbsql_pconnect' 'fbsql_connect';
  254.  
  255.         @ini_set('track_errors'true);
  256.         $php_errormsg '';
  257.         $connection @call_user_func_array($connect_function$params);
  258.         @ini_restore('track_errors');
  259.         if ($connection <= 0{
  260.             return $this->raiseError(MDB2_ERROR_CONNECT_FAILED);
  261.         }
  262.  
  263.         $this->connection = $connection;
  264.         $this->connected_dsn = $this->dsn;
  265.         $this->connected_database_name = '';
  266.         $this->opened_persistent = $this->options['persistent'];
  267.         $this->dbsyntax = $this->dsn['dbsyntax'$this->dsn['dbsyntax'$this->phptype;
  268.  
  269.         return MDB2_OK;
  270.     }
  271.  
  272.     // }}}
  273.     // {{{ disconnect()
  274.  
  275.     /**
  276.      * Log out and disconnect from the database.
  277.      *
  278.      * @return mixed true on success, false if not connected and error
  279.      *                 object on error
  280.      * @access public
  281.      */
  282.     function disconnect($force = true)
  283.     {
  284.         if (is_resource($this->connection)) {
  285.             if (!$this->opened_persistent || $force{
  286.                 @fbsql_close($this->connection);
  287.             }
  288.             $this->connection = 0;
  289.         }
  290.         return MDB2_OK;
  291.     }
  292.  
  293.     // }}}
  294.     // {{{ _doQuery()
  295.  
  296.     /**
  297.      * Execute a query
  298.      * @param string $query  query
  299.      * @param boolean $isManip  if the query is a manipulation query
  300.      * @param resource $connection 
  301.      * @param string $database_name 
  302.      * @return result or error object
  303.      * @access protected
  304.      */
  305.     function _doQuery($query$isManip = false$connection = null$database_name = null)
  306.     {
  307.         $this->last_query = $query;
  308.         $this->debug($query'query');
  309.         if ($this->options['disable_query']{
  310.             if ($isManip{
  311.                 return MDB2_OK;
  312.             }
  313.             return null;
  314.         }
  315.  
  316.         if (is_null($connection)) {
  317.             $error $this->connect();
  318.             if (PEAR::isError($error)) {
  319.                 return $error;
  320.             }
  321.             $connection $this->connection;
  322.         }
  323.         if (is_null($database_name)) {
  324.             $database_name $this->database_name;
  325.         }
  326.  
  327.         if ($database_name{
  328.             if ($database_name != $this->connected_database_name{
  329.                 if (!@fbsql_select_db($database_name$connection)) {
  330.                     return $this->raiseError();
  331.                 }
  332.                 $this->connected_database_name = $database_name;
  333.             }
  334.         }
  335.  
  336.         $result @fbsql_query($query$connection);
  337.         if (!$result{
  338.             return $this->raiseError();
  339.         }
  340.  
  341.         if ($isManip{
  342.             return @fbsql_affected_rows($connection);
  343.         }
  344.         return $result;
  345.     }
  346.  
  347.     // }}}
  348.     // {{{ _modifyQuery()
  349.  
  350.     /**
  351.      * Changes a query string for various DBMS specific reasons
  352.      *
  353.      * @param string $query  query to modify
  354.      * @return the new (modified) query
  355.      * @access protected
  356.      */
  357.     function _modifyQuery($query$isManip$limit$offset)
  358.     {
  359.         if ($limit > 0{
  360.             if ($isManip{
  361.                 return preg_replace('/^([\s(])*SELECT(?!\s*TOP\s*\()/i',
  362.                     "\\1SELECT TOP($limit)"$query);
  363.             else {
  364.                 return preg_replace('/([\s(])*SELECT(?!\s*TOP\s*\()/i',
  365.                     "\\1SELECT TOP($offset,$limit)"$query);
  366.             }
  367.         }
  368.         // Add ; to the end of the query. This is required by FrontBase
  369.         return $query.';';
  370.     }
  371.  
  372.     // }}}
  373.     // {{{ nextID()
  374.  
  375.     /**
  376.      * returns the next free id of a sequence
  377.      *
  378.      * @param string  $seq_name name of the sequence
  379.      * @param boolean $ondemand when true the seqence is
  380.      *                           automatic created, if it
  381.      *                           not exists
  382.      *
  383.      * @return mixed MDB2 Error Object or id
  384.      * @access public
  385.      */
  386.     function nextID($seq_name$ondemand = true)
  387.     {
  388.         $sequence_name $this->getSequenceName($seq_name);
  389.         $query = "INSERT INTO $sequence_name (".$this->options['seqcol_name'].") VALUES (NULL);";
  390.         $this->expectError(MDB2_ERROR_NOSUCHTABLE);
  391.         $result $this->_doQuery($querytrue);
  392.         $this->popExpect();
  393.         if (PEAR::isError($result)) {
  394.             if ($ondemand && $result->getCode(== MDB2_ERROR_NOSUCHTABLE{
  395.                 $this->loadModule('Manager');
  396.                 // Since we are creating the sequence on demand
  397.                 // we know the first id = 1 so initialize the
  398.                 // sequence at 2
  399.                 $result $this->manager->createSequence($seq_name2);
  400.                 if (PEAR::isError($result)) {
  401.                     return $this->raiseError(MDB2_ERRORnullnull,
  402.                         'nextID: on demand sequence '.$seq_name.' could not be created');
  403.                 else {
  404.                     // First ID of a newly created sequence is 1
  405.                     return 1;
  406.                 }
  407.             }
  408.             return $result;
  409.         }
  410.         $value $this->queryOne("SELECT UNIQUE FROM $sequence_name"'integer');
  411.         if (is_numeric($value)) {
  412.             $query = "DELETE FROM $sequence_name WHERE ".$this->options['seqcol_name']." < $value;";
  413.             $result $this->_doQuery($querytrue);
  414.             if(PEAR::isError($result)) {
  415.                 $this->warnings['nextID: could not delete previous sequence table values from '.$seq_name;
  416.             }
  417.         }
  418.         return $value;
  419.     }
  420.  
  421.     // }}}
  422.     // {{{ getAfterID()
  423.  
  424.     /**
  425.      * returns the autoincrement ID if supported or $id
  426.      *
  427.      * @param mixed $id value as returned by getBeforeId()
  428.      * @param string $table name of the table into which a new row was inserted
  429.      * @return mixed MDB2 Error Object or id
  430.      * @access public
  431.      */
  432.     function getAfterID($id$table)
  433.     {
  434.         $this->loadModule('Native');
  435.         return $this->native->getInsertID();
  436.     }
  437.  
  438.     // }}}
  439.     // {{{ currID()
  440.  
  441.     /**
  442.      * returns the current id of a sequence
  443.      *
  444.      * @param string  $seq_name name of the sequence
  445.      * @return mixed MDB2 Error Object or id
  446.      * @access public
  447.      */
  448.     function currID($seq_name)
  449.     {
  450.         $sequence_name $this->getSequenceName($seq_name);
  451.         $query "SELECT MAX(".$this->options['seqcol_name'].") FROM $sequence_name";
  452.         return $this->queryOne($query'integer');
  453.     }
  454.  
  455. }
  456.  
  457. class MDB2_Result_fbsql extends MDB2_Result_Common
  458. {
  459.     // }}}
  460.     // {{{ fetchRow()
  461.  
  462.     /**
  463.      * Fetch a row and insert the data into an existing array.
  464.      *
  465.      * @param int       $fetchmode  how the array data should be indexed
  466.      * @param int    $rownum    number of the row where the data can be found
  467.      * @return int data array on success, a MDB2 error on failure
  468.      * @access public
  469.      */
  470.     function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT$rownum = null)
  471.     {
  472.         if (!is_null($rownum)) {
  473.             $seek $this->seek($rownum);
  474.             if (PEAR::isError($seek)) {
  475.                 return $seek;
  476.             }
  477.         }
  478.         if ($fetchmode == MDB2_FETCHMODE_DEFAULT{
  479.             $fetchmode $this->db->fetchmode;
  480.         }
  481.         if ($fetchmode MDB2_FETCHMODE_ASSOC{
  482.             $row @fbsql_fetch_assoc($this->result);
  483.             if (is_array($row)
  484.                 && $this->db->options['portability'MDB2_PORTABILITY_LOWERCASE
  485.             {
  486.                 $row array_change_key_case($rowCASE_LOWER);
  487.             }
  488.         else {
  489.            $row @fbsql_fetch_row($this->result);
  490.         }
  491.         if (!$row{
  492.             if (is_null($this->result)) {
  493.                 return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  494.                     'fetchRow: resultset has already been freed');
  495.             }
  496.             return null;
  497.         }
  498.         if ($this->db->options['portability'MDB2_PORTABILITY_EMPTY_TO_NULL{
  499.             $this->db->_convertEmptyArrayValuesToNull($row);
  500.         }
  501.         if (isset($this->values)) {
  502.             $this->_assignBindColumns($row);
  503.         }
  504.         if (isset($this->types)) {
  505.             $row $this->db->datatype->convertResultRow($this->types$row);
  506.         }
  507.         if ($fetchmode === MDB2_FETCHMODE_OBJECT{
  508.             $object_class $this->db->options['fetch_class'];
  509.             if ($object_class == 'stdClass'{
  510.                 $row = (object) $row;
  511.             else {
  512.                 $row &new $object_class($row);
  513.             }
  514.         }
  515.         ++$this->rownum;
  516.         return $row;
  517.     }
  518.  
  519.     // }}}
  520.     // {{{ _getColumnNames()
  521.  
  522.     /**
  523.      * Retrieve the names of columns returned by the DBMS in a query result.
  524.      *
  525.      * @return mixed                an associative array variable
  526.      *                               that will hold the names of columns. The
  527.      *                               indexes of the array are the column names
  528.      *                               mapped to lower case and the values are the
  529.      *                               respective numbers of the columns starting
  530.      *                               from 0. Some DBMS may not return any
  531.      *                               columns when the result set does not
  532.      *                               contain any rows.
  533.      *
  534.      *                               a MDB2 error on failure
  535.      * @access private
  536.      */
  537.     function _getColumnNames()
  538.     {
  539.         $columns = array();
  540.         $numcols $this->numCols();
  541.         if (PEAR::isError($numcols)) {
  542.             return $numcols;
  543.         }
  544.         for ($column = 0; $column $numcols$column++{
  545.             $column_name @fbsql_field_name($this->result$column);
  546.             $columns[$column_name$column;
  547.         }
  548.         if ($this->db->options['portability'MDB2_PORTABILITY_LOWERCASE{
  549.             $columns array_change_key_case($columnsCASE_LOWER);
  550.         }
  551.         return $columns;
  552.     }
  553.  
  554.     // }}}
  555.     // {{{ numCols()
  556.  
  557.     /**
  558.      * Count the number of columns returned by the DBMS in a query result.
  559.      *
  560.      * @return mixed integer value with the number of columns, a MDB2 error
  561.      *                        on failure
  562.      * @access public
  563.      */
  564.     function numCols()
  565.     {
  566.         $cols @fbsql_num_fields($this->result);
  567.         if (is_null($cols)) {
  568.             if (is_null($this->result)) {
  569.                 return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  570.                     'numCols: resultset has already been freed');
  571.             }
  572.             return $this->db->raiseError();
  573.         }
  574.         return $cols;
  575.     }
  576.  
  577.     // }}}
  578.     // {{{ nextResult()
  579.  
  580.     /**
  581.      * Move the internal result pointer to the next available result
  582.      * Currently not supported
  583.      *
  584.      * @return true if a result is available otherwise return false
  585.      * @access public
  586.      */
  587.     function nextResult()
  588.     {
  589.         if (is_null($this->result)) {
  590.             return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  591.                 'nextResult: resultset has already been freed');
  592.         }
  593.         return @fbsql_next_result($this->result);
  594.     }
  595.  
  596.     // }}}
  597.     // {{{ free()
  598.  
  599.     /**
  600.      * Free the internal resources associated with result.
  601.      *
  602.      * @return boolean true on success, false if result is invalid
  603.      * @access public
  604.      */
  605.     function free()
  606.     {
  607.         $free @fbsql_free_result($this->result);
  608.         if (!$free{
  609.             if (is_null($this->result)) {
  610.                 return MDB2_OK;
  611.             }
  612.             return $this->db->raiseError();
  613.         }
  614.         $this->result = null;
  615.         return MDB2_OK;
  616.     }
  617. }
  618.  
  619. class MDB2_BufferedResult_fbsql extends MDB2_Result_fbsql
  620. {
  621.     // }}}
  622.     // {{{ seek()
  623.  
  624.     /**
  625.     * seek to a specific row in a result set
  626.     *
  627.     * @param int    $rownum    number of the row where the data can be found
  628.     * @return mixed MDB2_OK on success, a MDB2 error on failure
  629.     * @access public
  630.     */
  631.     function seek($rownum = 0)
  632.     {
  633.         if ($this->rownum != ($rownum - 1&& !@fbsql_data_seek($this->result$rownum)) {
  634.             if (is_null($this->result)) {
  635.                 return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  636.                     'seek: resultset has already been freed');
  637.             }
  638.             return $this->db->raiseError(MDB2_ERROR_INVALIDnullnull,
  639.                 'seek: tried to seek to an invalid row number ('.$rownum.')');
  640.         }
  641.         $this->rownum $rownum - 1;
  642.         return MDB2_OK;
  643.     }
  644.  
  645.     // }}}
  646.     // {{{ valid()
  647.  
  648.     /**
  649.     * check if the end of the result set has been reached
  650.     *
  651.     * @return mixed true or false on sucess, a MDB2 error on failure
  652.     * @access public
  653.     */
  654.     function valid()
  655.     {
  656.         $numrows $this->numRows();
  657.         if (PEAR::isError($numrows)) {
  658.             return $numrows;
  659.         }
  660.         return $this->rownum ($numrows - 1);
  661.     }
  662.  
  663.     // }}}
  664.     // {{{ numRows()
  665.  
  666.     /**
  667.     * returns the number of rows in a result object
  668.     *
  669.     * @return mixed MDB2 Error Object or the number of rows
  670.     * @access public
  671.     */
  672.     function numRows()
  673.     {
  674.         $rows @fbsql_num_rows($this->result);
  675.         if (is_null($rows)) {
  676.             if (is_null($this->result)) {
  677.                 return $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATAnullnull,
  678.                     'numRows: resultset has already been freed');
  679.             }
  680.             return $this->raiseError();
  681.         }
  682.         return $rows;
  683.     }
  684. }
  685.  
  686. class MDB2_Statement_fbsql extends MDB2_Statement_Common
  687. {
  688.  
  689. }
  690.  
  691. ?>

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