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

Source for file mysqli.php

Documentation is available at mysqli.php

  1. <?php
  2.  
  3. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  4.  
  5. /**
  6.  * The PEAR DB driver for PHP's mysqli extension
  7.  * for interacting with MySQL databases
  8.  *
  9.  * PHP versions 4 and 5
  10.  *
  11.  * LICENSE: This source file is subject to version 3.0 of the PHP license
  12.  * that is available through the world-wide-web at the following URI:
  13.  * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
  14.  * the PHP License and are unable to obtain it through the web, please
  15.  * send a note to license@php.net so we can mail you a copy immediately.
  16.  *
  17.  * @category   Database
  18.  * @package    DB
  19.  * @author     Daniel Convissor <danielc@php.net>
  20.  * @copyright  1997-2007 The PHP Group
  21.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  22.  * @version    CVS: $Id: mysqli.php,v 1.82 2007/09/21 13:40:41 aharvey Exp $
  23.  * @link       http://pear.php.net/package/DB
  24.  */
  25.  
  26. /**
  27.  * Obtain the DB_common class so it can be extended from
  28.  */
  29. require_once 'DB/common.php';
  30.  
  31. /**
  32.  * The methods PEAR DB uses to interact with PHP's mysqli extension
  33.  * for interacting with MySQL databases
  34.  *
  35.  * This is for MySQL versions 4.1 and above.  Requires PHP 5.
  36.  *
  37.  * Note that persistent connections no longer exist.
  38.  *
  39.  * These methods overload the ones declared in DB_common.
  40.  *
  41.  * @category   Database
  42.  * @package    DB
  43.  * @author     Daniel Convissor <danielc@php.net>
  44.  * @copyright  1997-2007 The PHP Group
  45.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  46.  * @version    Release: 1.7.14RC1
  47.  * @link       http://pear.php.net/package/DB
  48.  * @since      Class functional since Release 1.6.3
  49.  */
  50. class DB_mysqli extends DB_common
  51. {
  52.     // {{{ properties
  53.  
  54.     /**
  55.      * The DB driver type (mysql, oci8, odbc, etc.)
  56.      * @var string 
  57.      */
  58.     var $phptype = 'mysqli';
  59.  
  60.     /**
  61.      * The database syntax variant to be used (db2, access, etc.), if any
  62.      * @var string 
  63.      */
  64.     var $dbsyntax = 'mysqli';
  65.  
  66.     /**
  67.      * The capabilities of this DB implementation
  68.      *
  69.      * The 'new_link' element contains the PHP version that first provided
  70.      * new_link support for this DBMS.  Contains false if it's unsupported.
  71.      *
  72.      * Meaning of the 'limit' element:
  73.      *   + 'emulate' = emulate with fetch row by number
  74.      *   + 'alter'   = alter the query
  75.      *   + false     = skip rows
  76.      *
  77.      * @var array 
  78.      */
  79.     var $features = array(
  80.         'limit'         => 'alter',
  81.         'new_link'      => false,
  82.         'numrows'       => true,
  83.         'pconnect'      => false,
  84.         'prepare'       => false,
  85.         'ssl'           => true,
  86.         'transactions'  => true,
  87.     );
  88.  
  89.     /**
  90.      * A mapping of native error codes to DB error codes
  91.      * @var array 
  92.      */
  93.     var $errorcode_map = array(
  94.         1004 => DB_ERROR_CANNOT_CREATE,
  95.         1005 => DB_ERROR_CANNOT_CREATE,
  96.         1006 => DB_ERROR_CANNOT_CREATE,
  97.         1007 => DB_ERROR_ALREADY_EXISTS,
  98.         1008 => DB_ERROR_CANNOT_DROP,
  99.         1022 => DB_ERROR_ALREADY_EXISTS,
  100.         1044 => DB_ERROR_ACCESS_VIOLATION,
  101.         1046 => DB_ERROR_NODBSELECTED,
  102.         1048 => DB_ERROR_CONSTRAINT,
  103.         1049 => DB_ERROR_NOSUCHDB,
  104.         1050 => DB_ERROR_ALREADY_EXISTS,
  105.         1051 => DB_ERROR_NOSUCHTABLE,
  106.         1054 => DB_ERROR_NOSUCHFIELD,
  107.         1061 => DB_ERROR_ALREADY_EXISTS,
  108.         1062 => DB_ERROR_ALREADY_EXISTS,
  109.         1064 => DB_ERROR_SYNTAX,
  110.         1091 => DB_ERROR_NOT_FOUND,
  111.         1100 => DB_ERROR_NOT_LOCKED,
  112.         1136 => DB_ERROR_VALUE_COUNT_ON_ROW,
  113.         1142 => DB_ERROR_ACCESS_VIOLATION,
  114.         1146 => DB_ERROR_NOSUCHTABLE,
  115.         1216 => DB_ERROR_CONSTRAINT,
  116.         1217 => DB_ERROR_CONSTRAINT,
  117.         1356 => DB_ERROR_DIVZERO,
  118.         1451 => DB_ERROR_CONSTRAINT,
  119.         1452 => DB_ERROR_CONSTRAINT,
  120.     );
  121.  
  122.     /**
  123.      * The raw database connection created by PHP
  124.      * @var resource 
  125.      */
  126.     var $connection;
  127.  
  128.     /**
  129.      * The DSN information for connecting to a database
  130.      * @var array 
  131.      */
  132.     var $dsn = array();
  133.  
  134.  
  135.     /**
  136.      * Should data manipulation queries be committed automatically?
  137.      * @var bool 
  138.      * @access private
  139.      */
  140.     var $autocommit = true;
  141.  
  142.     /**
  143.      * The quantity of transactions begun
  144.      *
  145.      * {@internal  While this is private, it can't actually be designated
  146.      * private in PHP 5 because it is directly accessed in the test suite.}}}
  147.      *
  148.      * @var integer 
  149.      * @access private
  150.      */
  151.     var $transaction_opcount = 0;
  152.  
  153.     /**
  154.      * The database specified in the DSN
  155.      *
  156.      * It's a fix to allow calls to different databases in the same script.
  157.      *
  158.      * @var string 
  159.      * @access private
  160.      */
  161.     var $_db '';
  162.  
  163.     /**
  164.      * Array for converting MYSQLI_*_FLAG constants to text values
  165.      * @var    array 
  166.      * @access public
  167.      * @since  Property available since Release 1.6.5
  168.      */
  169.     var $mysqli_flags = array(
  170.         MYSQLI_NOT_NULL_FLAG        => 'not_null',
  171.         MYSQLI_PRI_KEY_FLAG         => 'primary_key',
  172.         MYSQLI_UNIQUE_KEY_FLAG      => 'unique_key',
  173.         MYSQLI_MULTIPLE_KEY_FLAG    => 'multiple_key',
  174.         MYSQLI_BLOB_FLAG            => 'blob',
  175.         MYSQLI_UNSIGNED_FLAG        => 'unsigned',
  176.         MYSQLI_ZEROFILL_FLAG        => 'zerofill',
  177.         MYSQLI_AUTO_INCREMENT_FLAG  => 'auto_increment',
  178.         MYSQLI_TIMESTAMP_FLAG       => 'timestamp',
  179.         MYSQLI_SET_FLAG             => 'set',
  180.         // MYSQLI_NUM_FLAG             => 'numeric',  // unnecessary
  181.         // MYSQLI_PART_KEY_FLAG        => 'multiple_key',  // duplicatvie
  182.         MYSQLI_GROUP_FLAG           => 'group_by'
  183.     );
  184.  
  185.     /**
  186.      * Array for converting MYSQLI_TYPE_* constants to text values
  187.      * @var    array 
  188.      * @access public
  189.      * @since  Property available since Release 1.6.5
  190.      */
  191.     var $mysqli_types = array(
  192.         MYSQLI_TYPE_DECIMAL     => 'decimal',
  193.         MYSQLI_TYPE_TINY        => 'tinyint',
  194.         MYSQLI_TYPE_SHORT       => 'int',
  195.         MYSQLI_TYPE_LONG        => 'int',
  196.         MYSQLI_TYPE_FLOAT       => 'float',
  197.         MYSQLI_TYPE_DOUBLE      => 'double',
  198.         // MYSQLI_TYPE_NULL        => 'DEFAULT NULL',  // let flags handle it
  199.         MYSQLI_TYPE_TIMESTAMP   => 'timestamp',
  200.         MYSQLI_TYPE_LONGLONG    => 'bigint',
  201.         MYSQLI_TYPE_INT24       => 'mediumint',
  202.         MYSQLI_TYPE_DATE        => 'date',
  203.         MYSQLI_TYPE_TIME        => 'time',
  204.         MYSQLI_TYPE_DATETIME    => 'datetime',
  205.         MYSQLI_TYPE_YEAR        => 'year',
  206.         MYSQLI_TYPE_NEWDATE     => 'date',
  207.         MYSQLI_TYPE_ENUM        => 'enum',
  208.         MYSQLI_TYPE_SET         => 'set',
  209.         MYSQLI_TYPE_TINY_BLOB   => 'tinyblob',
  210.         MYSQLI_TYPE_MEDIUM_BLOB => 'mediumblob',
  211.         MYSQLI_TYPE_LONG_BLOB   => 'longblob',
  212.         MYSQLI_TYPE_BLOB        => 'blob',
  213.         MYSQLI_TYPE_VAR_STRING  => 'varchar',
  214.         MYSQLI_TYPE_STRING      => 'char',
  215.         MYSQLI_TYPE_GEOMETRY    => 'geometry',
  216.         /* These constants are conditionally compiled in ext/mysqli, so we'll
  217.          * define them by number rather than constant. */
  218.         16                      => 'bit',
  219.         246                     => 'decimal',
  220.     );
  221.  
  222.  
  223.     // }}}
  224.     // {{{ constructor
  225.  
  226.     /**
  227.      * This constructor calls <kbd>$this->DB_common()</kbd>
  228.      *
  229.      * @return void 
  230.      */
  231.     function DB_mysqli()
  232.     {
  233.         $this->DB_common();
  234.     }
  235.  
  236.     // }}}
  237.     // {{{ connect()
  238.  
  239.     /**
  240.      * Connect to the database server, log in and open the database
  241.      *
  242.      * Don't call this method directly.  Use DB::connect() instead.
  243.      *
  244.      * PEAR DB's mysqli driver supports the following extra DSN options:
  245.      *   + When the 'ssl' $option passed to DB::connect() is true:
  246.      *     + key      The path to the key file.
  247.      *     + cert     The path to the certificate file.
  248.      *     + ca       The path to the certificate authority file.
  249.      *     + capath   The path to a directory that contains trusted SSL
  250.      *                 CA certificates in pem format.
  251.      *     + cipher   The list of allowable ciphers for SSL encryption.
  252.      *
  253.      * Example of how to connect using SSL:
  254.      * <code>
  255.      * require_once 'DB.php';
  256.      * 
  257.      * $dsn = array(
  258.      *     'phptype'  => 'mysqli',
  259.      *     'username' => 'someuser',
  260.      *     'password' => 'apasswd',
  261.      *     'hostspec' => 'localhost',
  262.      *     'database' => 'thedb',
  263.      *     'key'      => 'client-key.pem',
  264.      *     'cert'     => 'client-cert.pem',
  265.      *     'ca'       => 'cacert.pem',
  266.      *     'capath'   => '/path/to/ca/dir',
  267.      *     'cipher'   => 'AES',
  268.      * );
  269.      * 
  270.      * $options = array(
  271.      *     'ssl' => true,
  272.      * );
  273.      * 
  274.      * $db = DB::connect($dsn, $options);
  275.      * if (PEAR::isError($db)) {
  276.      *     die($db->getMessage());
  277.      * }
  278.      * </code>
  279.      *
  280.      * @param array $dsn         the data source name
  281.      * @param bool  $persistent  should the connection be persistent?
  282.      *
  283.      * @return int  DB_OK on success. A DB_Error object on failure.
  284.      */
  285.     function connect($dsn$persistent = false)
  286.     {
  287.         if (!PEAR::loadExtension('mysqli')) {
  288.             return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
  289.         }
  290.  
  291.         $this->dsn = $dsn;
  292.         if ($dsn['dbsyntax']{
  293.             $this->dbsyntax = $dsn['dbsyntax'];
  294.         }
  295.  
  296.         $ini ini_get('track_errors');
  297.         @ini_set('track_errors'1);
  298.         $php_errormsg '';
  299.  
  300.         if (((int) $this->getOption('ssl')) === 1{
  301.             $init = mysqli_init();
  302.             mysqli_ssl_set(
  303.                 $init,
  304.                 empty($dsn['key'])    ? null : $dsn['key'],
  305.                 empty($dsn['cert'])   ? null : $dsn['cert'],
  306.                 empty($dsn['ca'])     ? null : $dsn['ca'],
  307.                 empty($dsn['capath']? null : $dsn['capath'],
  308.                 empty($dsn['cipher']? null : $dsn['cipher']
  309.             );
  310.             if ($this->connection = @mysqli_real_connect(
  311.                     $init,
  312.                     $dsn['hostspec'],
  313.                     $dsn['username'],
  314.                     $dsn['password'],
  315.                     $dsn['database'],
  316.                     $dsn['port'],
  317.                     $dsn['socket']))
  318.             {
  319.                 $this->connection = $init;
  320.             }
  321.         else {
  322.             $this->connection = @mysqli_connect(
  323.                 $dsn['hostspec'],
  324.                 $dsn['username'],
  325.                 $dsn['password'],
  326.                 $dsn['database'],
  327.                 $dsn['port'],
  328.                 $dsn['socket']
  329.             );
  330.         }
  331.  
  332.         @ini_set('track_errors'$ini);
  333.  
  334.         if (!$this->connection{
  335.             if (($err @mysqli_connect_error()) != ''{
  336.                 return $this->raiseError(DB_ERROR_CONNECT_FAILED,
  337.                                          nullnullnull,
  338.                                          $err);
  339.             else {
  340.                 return $this->raiseError(DB_ERROR_CONNECT_FAILED,
  341.                                          nullnullnull,
  342.                                          $php_errormsg);
  343.             }
  344.         }
  345.  
  346.         if ($dsn['database']{
  347.             $this->_db $dsn['database'];
  348.         }
  349.  
  350.         return DB_OK;
  351.     }
  352.  
  353.     // }}}
  354.     // {{{ disconnect()
  355.  
  356.     /**
  357.      * Disconnects from the database server
  358.      *
  359.      * @return bool  TRUE on success, FALSE on failure
  360.      */
  361.     function disconnect()
  362.     {
  363.         $ret @mysqli_close($this->connection);
  364.         $this->connection = null;
  365.         return $ret;
  366.     }
  367.  
  368.     // }}}
  369.     // {{{ simpleQuery()
  370.  
  371.     /**
  372.      * Sends a query to the database server
  373.      *
  374.      * @param string  the SQL query string
  375.      *
  376.      * @return mixed  + a PHP result resrouce for successful SELECT queries
  377.      *                 + the DB_OK constant for other successful queries
  378.      *                 + a DB_Error object on failure
  379.      */
  380.     function simpleQuery($query)
  381.     {
  382.         $ismanip $this->_checkManip($query);
  383.         $this->last_query = $query;
  384.         $query $this->modifyQuery($query);
  385.         if ($this->_db{
  386.             if (!@mysqli_select_db($this->connection$this->_db)) {
  387.                 return $this->mysqliRaiseError(DB_ERROR_NODBSELECTED);
  388.             }
  389.         }
  390.         if (!$this->autocommit && $ismanip{
  391.             if ($this->transaction_opcount == 0{
  392.                 $result @mysqli_query($this->connection'SET AUTOCOMMIT=0');
  393.                 $result @mysqli_query($this->connection'BEGIN');
  394.                 if (!$result{
  395.                     return $this->mysqliRaiseError();
  396.                 }
  397.             }
  398.             $this->transaction_opcount++;
  399.         }
  400.         $result @mysqli_query($this->connection$query);
  401.         if (!$result{
  402.             return $this->mysqliRaiseError();
  403.         }
  404.         if (is_object($result)) {
  405.             return $result;
  406.         }
  407.         return DB_OK;
  408.     }
  409.  
  410.     // }}}
  411.     // {{{ nextResult()
  412.  
  413.     /**
  414.      * Move the internal mysql result pointer to the next available result.
  415.      *
  416.      * This method has not been implemented yet.
  417.      *
  418.      * @param resource $result a valid sql result resource
  419.      * @return false 
  420.      * @access public
  421.      */
  422.     function nextResult($result)
  423.     {
  424.         return false;
  425.     }
  426.  
  427.     // }}}
  428.     // {{{ fetchInto()
  429.  
  430.     /**
  431.      * Places a row from the result set into the given array
  432.      *
  433.      * Formating of the array and the data therein are configurable.
  434.      * See DB_result::fetchInto() for more information.
  435.      *
  436.      * This method is not meant to be called directly.  Use
  437.      * DB_result::fetchInto() instead.  It can't be declared "protected"
  438.      * because DB_result is a separate object.
  439.      *
  440.      * @param resource $result    the query result resource
  441.      * @param array    $arr       the referenced array to put the data in
  442.      * @param int      $fetchmode how the resulting array should be indexed
  443.      * @param int      $rownum    the row number to fetch (0 = first row)
  444.      *
  445.      * @return mixed  DB_OK on success, NULL when the end of a result set is
  446.      *                  reached or on failure
  447.      *
  448.      * @see DB_result::fetchInto()
  449.      */
  450.     function fetchInto($result&$arr$fetchmode$rownum = null)
  451.     {
  452.         if ($rownum !== null{
  453.             if (!@mysqli_data_seek($result$rownum)) {
  454.                 return null;
  455.             }
  456.         }
  457.         if ($fetchmode DB_FETCHMODE_ASSOC{
  458.             $arr @mysqli_fetch_array($resultMYSQLI_ASSOC);
  459.             if ($this->options['portability'DB_PORTABILITY_LOWERCASE && $arr{
  460.                 $arr array_change_key_case($arrCASE_LOWER);
  461.             }
  462.         else {
  463.             $arr @mysqli_fetch_row($result);
  464.         }
  465.         if (!$arr{
  466.             return null;
  467.         }
  468.         if ($this->options['portability'DB_PORTABILITY_RTRIM{
  469.             /*
  470.              * Even though this DBMS already trims output, we do this because
  471.              * a field might have intentional whitespace at the end that
  472.              * gets removed by DB_PORTABILITY_RTRIM under another driver.
  473.              */
  474.             $this->_rtrimArrayValues($arr);
  475.         }
  476.         if ($this->options['portability'DB_PORTABILITY_NULL_TO_EMPTY{
  477.             $this->_convertNullArrayValuesToEmpty($arr);
  478.         }
  479.         return DB_OK;
  480.     }
  481.  
  482.     // }}}
  483.     // {{{ freeResult()
  484.  
  485.     /**
  486.      * Deletes the result set and frees the memory occupied by the result set
  487.      *
  488.      * This method is not meant to be called directly.  Use
  489.      * DB_result::free() instead.  It can't be declared "protected"
  490.      * because DB_result is a separate object.
  491.      *
  492.      * @param resource $result  PHP's query result resource
  493.      *
  494.      * @return bool  TRUE on success, FALSE if $result is invalid
  495.      *
  496.      * @see DB_result::free()
  497.      */
  498.     function freeResult($result)
  499.     {
  500.         return is_resource($result? mysqli_free_result($result: false;
  501.     }
  502.  
  503.     // }}}
  504.     // {{{ numCols()
  505.  
  506.     /**
  507.      * Gets the number of columns in a result set
  508.      *
  509.      * This method is not meant to be called directly.  Use
  510.      * DB_result::numCols() instead.  It can't be declared "protected"
  511.      * because DB_result is a separate object.
  512.      *
  513.      * @param resource $result  PHP's query result resource
  514.      *
  515.      * @return int  the number of columns.  A DB_Error object on failure.
  516.      *
  517.      * @see DB_result::numCols()
  518.      */
  519.     function numCols($result)
  520.     {
  521.         $cols @mysqli_num_fields($result);
  522.         if (!$cols{
  523.             return $this->mysqliRaiseError();
  524.         }
  525.         return $cols;
  526.     }
  527.  
  528.     // }}}
  529.     // {{{ numRows()
  530.  
  531.     /**
  532.      * Gets the number of rows in a result set
  533.      *
  534.      * This method is not meant to be called directly.  Use
  535.      * DB_result::numRows() instead.  It can't be declared "protected"
  536.      * because DB_result is a separate object.
  537.      *
  538.      * @param resource $result  PHP's query result resource
  539.      *
  540.      * @return int  the number of rows.  A DB_Error object on failure.
  541.      *
  542.      * @see DB_result::numRows()
  543.      */
  544.     function numRows($result)
  545.     {
  546.         $rows @mysqli_num_rows($result);
  547.         if ($rows === null{
  548.             return $this->mysqliRaiseError();
  549.         }
  550.         return $rows;
  551.     }
  552.  
  553.     // }}}
  554.     // {{{ autoCommit()
  555.  
  556.     /**
  557.      * Enables or disables automatic commits
  558.      *
  559.      * @param bool $onoff  true turns it on, false turns it off
  560.      *
  561.      * @return int  DB_OK on success.  A DB_Error object if the driver
  562.      *                doesn't support auto-committing transactions.
  563.      */
  564.     function autoCommit($onoff = false)
  565.     {
  566.         // XXX if $this->transaction_opcount > 0, we should probably
  567.         // issue a warning here.
  568.         $this->autocommit $onoff ? true : false;
  569.         return DB_OK;
  570.     }
  571.  
  572.     // }}}
  573.     // {{{ commit()
  574.  
  575.     /**
  576.      * Commits the current transaction
  577.      *
  578.      * @return int  DB_OK on success.  A DB_Error object on failure.
  579.      */
  580.     function commit()
  581.     {
  582.         if ($this->transaction_opcount > 0{
  583.             if ($this->_db{
  584.                 if (!@mysqli_select_db($this->connection$this->_db)) {
  585.                     return $this->mysqliRaiseError(DB_ERROR_NODBSELECTED);
  586.                 }
  587.             }
  588.             $result @mysqli_query($this->connection'COMMIT');
  589.             $result @mysqli_query($this->connection'SET AUTOCOMMIT=1');
  590.             $this->transaction_opcount = 0;
  591.             if (!$result{
  592.                 return $this->mysqliRaiseError();
  593.             }
  594.         }
  595.         return DB_OK;
  596.     }
  597.  
  598.     // }}}
  599.     // {{{ rollback()
  600.  
  601.     /**
  602.      * Reverts the current transaction
  603.      *
  604.      * @return int  DB_OK on success.  A DB_Error object on failure.
  605.      */
  606.     function rollback()
  607.     {
  608.         if ($this->transaction_opcount > 0{
  609.             if ($this->_db{
  610.                 if (!@mysqli_select_db($this->connection$this->_db)) {
  611.                     return $this->mysqliRaiseError(DB_ERROR_NODBSELECTED);
  612.                 }
  613.             }
  614.             $result @mysqli_query($this->connection'ROLLBACK');
  615.             $result @mysqli_query($this->connection'SET AUTOCOMMIT=1');
  616.             $this->transaction_opcount = 0;
  617.             if (!$result{
  618.                 return $this->mysqliRaiseError();
  619.             }
  620.         }
  621.         return DB_OK;
  622.     }
  623.  
  624.     // }}}
  625.     // {{{ affectedRows()
  626.  
  627.     /**
  628.      * Determines the number of rows affected by a data maniuplation query
  629.      *
  630.      * 0 is returned for queries that don't manipulate data.
  631.      *
  632.      * @return int  the number of rows.  A DB_Error object on failure.
  633.      */
  634.     function affectedRows()
  635.     {
  636.         if ($this->_last_query_manip{
  637.             return @mysqli_affected_rows($this->connection);
  638.         else {
  639.             return 0;
  640.         }
  641.      }
  642.  
  643.     // }}}
  644.     // {{{ nextId()
  645.  
  646.     /**
  647.      * Returns the next free id in a sequence
  648.      *
  649.      * @param string  $seq_name  name of the sequence
  650.      * @param boolean $ondemand  when true, the seqence is automatically
  651.      *                             created if it does not exist
  652.      *
  653.      * @return int  the next id number in the sequence.
  654.      *                A DB_Error object on failure.
  655.      *
  656.      * @see DB_common::nextID(), DB_common::getSequenceName(),
  657.      *       DB_mysqli::createSequence(), DB_mysqli::dropSequence()
  658.      */
  659.     function nextId($seq_name$ondemand = true)
  660.     {
  661.         $seqname $this->getSequenceName($seq_name);
  662.         do {
  663.             $repeat = 0;
  664.             $this->pushErrorHandling(PEAR_ERROR_RETURN);
  665.             $result $this->query('UPDATE ' $seqname
  666.