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