DB_dbase Class Reference

Inheritance diagram for DB_dbase:

Inheritance graph
[legend]
Collaboration diagram for DB_dbase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DB_dbase ()
 connect ($dsn, $persistent=false)
 disconnect ()
query ($query=null)
 fetchInto ($result, &$arr, $fetchmode, $rownum=null)
 numCols ($foo)
 numRows ($foo)
 quoteSmart ($in)
 tableInfo ($result=null, $mode=null)
 __sleep ()
 __wakeup ()
 __toString ()
 toString ()
 quoteString ($string)
 quote ($string=null)
 quoteIdentifier ($str)
 escapeSimple ($str)
 provides ($feature)
 setFetchMode ($fetchmode, $object_class= 'stdClass')
 setOption ($option, $value)
 getOption ($option)
 prepare ($query)
 autoPrepare ($table, $table_fields, $mode=DB_AUTOQUERY_INSERT, $where=false)
 autoExecute ($table, $fields_values, $mode=DB_AUTOQUERY_INSERT, $where=false)
 buildManipSQL ($table, $table_fields, $mode, $where=false)
execute ($stmt, $data=array())
 executeEmulateQuery ($stmt, $data=array())
 executeMultiple ($stmt, $data)
 freePrepared ($stmt, $free_resource=true)
 modifyQuery ($query)
 modifyLimitQuery ($query, $from, $count, $params=array())
query ($query, $params=array())
limitQuery ($query, $from, $count, $params=array())
getOne ($query, $params=array())
getRow ($query, $params=array(), $fetchmode=DB_FETCHMODE_DEFAULT)
getCol ($query, $col=0, $params=array())
getAssoc ($query, $force_array=false, $params=array(), $fetchmode=DB_FETCHMODE_DEFAULT, $group=false)
getAll ($query, $params=array(), $fetchmode=DB_FETCHMODE_DEFAULT)
 autoCommit ($onoff=false)
 commit ()
 rollback ()
 affectedRows ()
 getSequenceName ($sqn)
 nextId ($seq_name, $ondemand=true)
 createSequence ($seq_name)
 dropSequence ($seq_name)
raiseError ($code=DB_ERROR, $mode=null, $options=null, $userinfo=null, $nativecode=null)
 raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 errorNative ()
 errorCode ($nativecode)
 errorMessage ($dbcode)
 getTables ()
 getListOf ($type)
 getSpecialQuery ($type)
 _rtrimArrayValues (&$array)
 _convertNullArrayValuesToEmpty (&$array)
 _PEAR ()
getStaticProperty ($class, $var)
 registerShutdownFunc ($func, $args=array())
 isError ($data, $code=null)
 setErrorHandling ($mode=null, $options=null)
 expectError ($code= '*')
 popExpect ()
 _checkDelExpect ($error_code)
 delExpect ($error_code)
 throwError ($message=null, $code=null, $userinfo=null)
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 popErrorHandling ()
 loadExtension ($ext)

Public Attributes

 $phptype = 'dbase'
 $dbsyntax = 'dbase'
 $features
 $errorcode_map
 $connection
 $dsn = array()
 $res_row = array()
 $result = 0
 $types
 $fetchmode = DB_FETCHMODE_ORDERED
 $fetchmode_object_class = 'stdClass'
 $was_connected = null
 $last_query = ''
 $options
 $last_parameters = array()
 $prepare_tokens = array()
 $prepare_types = array()
 $prepared_queries = array()
 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Detailed Description

Definition at line 47 of file dbase.php.


Constructor & Destructor Documentation

DB_dbase::DB_dbase  ) 
 

This constructor calls $this->DB_common()

Returns:
void

Definition at line 147 of file dbase.php.

References DB_common::DB_common().

00148     {
00149         $this->DB_common();
00150     }


Member Function Documentation

DB_common::__sleep  )  [inherited]
 

Automatically indicates which properties should be saved when PHP's serialize() function is called

Returns:
array the array of properties names that should be saved

Definition at line 147 of file common.php.

00148     {
00149         if ($this->connection) {
00150             // Don't disconnect(), people use serialize() for many reasons
00151             $this->was_connected = true;
00152         } else {
00153             $this->was_connected = false;
00154         }
00155         if (isset($this->autocommit)) {
00156             return array('autocommit',
00157                          'dbsyntax',
00158                          'dsn',
00159                          'features',
00160                          'fetchmode',
00161                          'fetchmode_object_class',
00162                          'options',
00163                          'was_connected',
00164                    );
00165         } else {
00166             return array('dbsyntax',
00167                          'dsn',
00168                          'features',
00169                          'fetchmode',
00170                          'fetchmode_object_class',
00171                          'options',
00172                          'was_connected',
00173                    );
00174         }
00175     }

DB_common::__toString  )  [inherited]
 

Automatic string conversion for PHP 5

Returns:
string a string describing the current PEAR DB object
Since:
Method available since Release 1.7.0

Definition at line 206 of file common.php.

References $info.

Referenced by DB_common::toString().

00207     {
00208         $info = strtolower(get_class($this));
00209         $info .=  ': (phptype=' . $this->phptype .
00210                   ', dbsyntax=' . $this->dbsyntax .
00211                   ')';
00212         if ($this->connection) {
00213             $info .= ' [connected]';
00214         }
00215         return $info;
00216     }

DB_common::__wakeup  )  [inherited]
 

Automatically reconnects to the database when PHP's unserialize() function is called

The reconnection attempt is only performed if the object was connected at the time PHP's serialize() function was run.

Returns:
void

Definition at line 189 of file common.php.

00190     {
00191         if ($this->was_connected) {
00192             $this->connect($this->dsn, $this->options);
00193         }
00194     }

PEAR::_checkDelExpect error_code  )  [inherited]
 

This method checks unsets an error code if available

Parameters:
mixed error code
Returns:
bool true if the error code was unset, false otherwise private
Since:
PHP 4.3.0

Definition at line 396 of file PEAR.php.

00397     {
00398         $deleted = false;
00399 
00400         foreach ($this->_expected_errors AS $key => $error_array) {
00401             if (in_array($error_code, $error_array)) {
00402                 unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
00403                 $deleted = true;
00404             }
00405 
00406             // clean up empty arrays
00407             if (0 == count($this->_expected_errors[$key])) {
00408                 unset($this->_expected_errors[$key]);
00409             }
00410         }
00411         return $deleted;
00412     }

DB_common::_convertNullArrayValuesToEmpty &$  array  )  [inherited]
 

Converts all null values in an array to empty strings

Parameters:
array $array the array to be de-nullified (passed by reference)
Returns:
void
protected

Definition at line 2138 of file common.php.

Referenced by DB_sybase::fetchInto(), DB_sqlite::fetchInto(), DB_odbc::fetchInto(), DB_oci8::fetchInto(), DB_mysqli::fetchInto(), DB_mysql::fetchInto(), DB_mssql::fetchInto(), DB_msql::fetchInto(), DB_ifx::fetchInto(), DB_fbsql::fetchInto(), and fetchInto().

02139     {
02140         foreach ($array as $key => $value) {
02141             if (is_null($value)) {
02142                 $array[$key] = '';
02143             }
02144         }
02145     }

PEAR::_PEAR  )  [inherited]
 

Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.

See the note in the class desciption about output from destructors.

public

Returns:
void

Definition at line 192 of file PEAR.php.

00192                      {
00193         if ($this->_debug) {
00194             printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
00195         }
00196     }

DB_common::_rtrimArrayValues &$  array  )  [inherited]
 

Right-trims all strings in an array

Parameters:
array $array the array to be trimmed (passed by reference)
Returns:
void
protected

Definition at line 2117 of file common.php.

Referenced by DB_sybase::fetchInto(), DB_sqlite::fetchInto(), DB_odbc::fetchInto(), DB_oci8::fetchInto(), DB_mysqli::fetchInto(), DB_mysql::fetchInto(), DB_mssql::fetchInto(), DB_msql::fetchInto(), DB_ifx::fetchInto(), DB_fbsql::fetchInto(), and fetchInto().

02118     {
02119         foreach ($array as $key => $value) {
02120             if (is_string($value)) {
02121                 $array[$key] = rtrim($value);
02122             }
02123         }
02124     }

DB_common::affectedRows  )  [inherited]
 

Determines the number of rows affected by a data maniuplation query

0 is returned for queries that don't manipulate data.

Returns:
int the number of rows. A DB_Error object on failure.

Reimplemented in DB_fbsql, DB_ibase, DB_ifx, DB_msql, DB_mssql, DB_mysql, DB_mysqli, DB_oci8, DB_odbc, DB_pgsql, DB_sqlite, and DB_sybase.

Definition at line 1703 of file common.php.

References DB_common::raiseError().

01704     {
01705         return $this->raiseError(DB_ERROR_NOT_CAPABLE);
01706     }

DB_common::autoCommit onoff = false  )  [inherited]
 

Enables or disables automatic commits

Parameters:
bool $onoff true turns it on, false turns it off
Returns:
int DB_OK on success. A DB_Error object if the driver doesn't support auto-committing transactions.

Reimplemented in DB_fbsql, DB_ibase, DB_ifx, DB_mssql, DB_mysql, DB_mysqli, DB_oci8, DB_odbc, DB_pgsql, and DB_sybase.

Definition at line 1647 of file common.php.

References DB_common::raiseError().

01648     {
01649         return $this->raiseError(DB_ERROR_NOT_CAPABLE);
01650     }

DB_common::autoExecute table,
fields_values,
mode = DB_AUTOQUERY_INSERT,
where = false
[inherited]
 

Automaticaly generates an insert or update query and call prepare() and execute() with it

Parameters:
string $table the table name
array $fields_values the associative array where $key is a field name and $value its value
int $mode a type of query to make: DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE
string $where for update queries: the WHERE clause to append to the SQL statement. Don't include the "WHERE" keyword.
Returns:
mixed a new DB_result object for successful SELECT queries or DB_OK for successul data manipulation queries. A DB_Error object on failure.
DB_common::autoPrepare(), DB_common::execute()

Definition at line 832 of file common.php.

References DB_common::autoPrepare(), DB_common::execute(), DB_common::freePrepared(), and DB::isError().

00834     {
00835         $sth = $this->autoPrepare($table, array_keys($fields_values), $mode,
00836                                   $where);
00837         if (DB::isError($sth)) {
00838             return $sth;
00839         }
00840         $ret =& $this->execute($sth, array_values($fields_values));
00841         $this->freePrepared($sth);
00842         return $ret;
00843 
00844     }

DB_common::autoPrepare table,
table_fields,
mode = DB_AUTOQUERY_INSERT,
where = false
[inherited]
 

Automaticaly generates an insert or update query and pass it to prepare()

Parameters:
string $table the table name
array $table_fields the array of field names
int $mode a type of query to make: DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE
string $where for update queries: the WHERE clause to append to the SQL statement. Don't include the "WHERE" keyword.
Returns:
resource the query handle
DB_common::prepare(), DB_common::buildManipSQL()

Definition at line 800 of file common.php.

References $query, DB_common::buildManipSQL(), DB::isError(), DB_common::prepare(), and DB_common::query().

Referenced by DB_common::autoExecute().

00802     {
00803         $query = $this->buildManipSQL($table, $table_fields, $mode, $where);
00804         if (DB::isError($query)) {
00805             return $query;
00806         }
00807         return $this->prepare($query);
00808     }

DB_common::buildManipSQL table,
table_fields,
mode,
where = false
[inherited]
 

Produces an SQL query string for autoPrepare()

Example:

 buildManipSQL('table_sql', array('field1', 'field2', 'field3'),
               DB_AUTOQUERY_INSERT);
 

That returns <samp> INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?) </samp>

NOTES:

  • This belongs more to a SQL Builder class, but this is a simple facility.
  • Be carefull! If you don't give a $where param with an UPDATE query, all the records of the table will be updated!

Parameters:
string $table the table name
array $table_fields the array of field names
int $mode a type of query to make: DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE
string $where for update queries: the WHERE clause to append to the SQL statement. Don't include the "WHERE" keyword.
Returns:
string the sql query for autoPrepare()

Definition at line 879 of file common.php.

References $set, $sql, $value, $values, and DB_common::raiseError().

Referenced by DB_common::autoPrepare().

00880     {
00881         if (count($table_fields) == 0) {
00882             return $this->raiseError(DB_ERROR_NEED_MORE_DATA);
00883         }
00884         $first = true;
00885         switch ($mode) {
00886             case DB_AUTOQUERY_INSERT:
00887                 $values = '';
00888                 $names = '';
00889                 foreach ($table_fields as $value) {
00890                     if ($first) {
00891                         $first = false;
00892                     } else {
00893                         $names .= ',';
00894                         $values .= ',';
00895                     }
00896                     $names .= $value;
00897                     $values .= '?';
00898                 }
00899                 return "INSERT INTO $table ($names) VALUES ($values)";
00900             case DB_AUTOQUERY_UPDATE:
00901                 $set = '';
00902                 foreach ($table_fields as $value) {
00903                     if ($first) {
00904                         $first = false;
00905                     } else {
00906                         $set .= ',';
00907                     }
00908                     $set .= "$value = ?";
00909                 }
00910                 $sql = "UPDATE $table SET $set";
00911                 if ($where) {
00912                     $sql .= " WHERE $where";
00913                 }
00914                 return $sql;
00915             default:
00916                 return $this->raiseError(DB_ERROR_SYNTAX);
00917         }
00918     }

DB_common::commit  )  [inherited]
 

Commits the current transaction

Returns:
int DB_OK on success. A DB_Error object on failure.

Reimplemented in DB_fbsql, DB_ibase, DB_ifx, DB_mssql, DB_mysql, DB_mysqli, DB_oci8, DB_odbc, DB_pgsql, and DB_sybase.

Definition at line 1660 of file common.php.

References DB_common::raiseError().

01661     {
01662         return $this->raiseError(DB_ERROR_NOT_CAPABLE);
01663     }

DB_dbase::connect dsn,
persistent = false
 

Connect to the database and create it if it doesn't exist

Don't call this method directly. Use DB::connect() instead.

PEAR DB's dbase driver supports the following extra DSN options: + mode An integer specifying the read/write mode to use (0 = read only, 1 = write only, 2 = read/write). Available since PEAR DB 1.7.0. + fields An array of arrays that PHP's dbase_create() function needs to create a new database. This information is used if the dBase file specified in the "database" segment of the DSN does not exist. For more info, see the PHP manual's dbase_create() page. Available since PEAR DB 1.7.0.

Example of how to connect and establish a new dBase file if necessary: require_once 'DB.php';

$dsn = array( 'phptype' => 'dbase', 'database' => '/path/and/name/of/dbase/file', 'mode' => 2, 'fields' => array( array('a', 'N', 5, 0), array('b', 'C', 40), array('c', 'C', 255), array('d', 'C', 20), ), ); $options = array( 'debug' => 2, 'portability' => DB_PORTABILITY_ALL, );

$db =& DB::connect($dsn, $options); if (PEAR::isError($db)) { die($db->getMessage()); }

Parameters:
array $dsn the data source name
bool $persistent should the connection be persistent?
Returns:
int DB_OK on success. A DB_Error object on failure.

Definition at line 202 of file dbase.php.

References $dsn, PEAR::loadExtension(), and DB_common::raiseError().

00203     {
00204         if (!PEAR::loadExtension('dbase')) {
00205             return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
00206         }
00207 
00208         $this->dsn = $dsn;
00209         if ($dsn['dbsyntax']) {
00210             $this->dbsyntax = $dsn['dbsyntax'];
00211         }
00212 
00213         /*
00214          * Turn track_errors on for entire script since $php_errormsg
00215          * is the only way to find errors from the dbase extension.
00216          */
00217         ini_set('track_errors', 1);
00218         $php_errormsg = '';
00219 
00220         if (!file_exists($dsn['database'])) {
00221             $this->dsn['mode'] = 2;
00222             if (empty($dsn['fields']) || !is_array($dsn['fields'])) {
00223                 return $this->raiseError(DB_ERROR_CONNECT_FAILED,
00224                                          null, null, null,
00225                                          'the dbase file does not exist and '
00226                                          . 'it could not be created because '
00227                                          . 'the "fields" element of the DSN '
00228                                          . 'is not properly set');
00229             }
00230             $this->connection = @dbase_create($dsn['database'],
00231                                               $dsn['fields']);
00232             if (!$this->connection) {
00233                 return $this->raiseError(DB_ERROR_CONNECT_FAILED,
00234                                          null, null, null,
00235                                          'the dbase file does not exist and '
00236                                          . 'the attempt to create it failed: '
00237                                          . $php_errormsg);
00238             }
00239         } else {
00240             if (!isset($this->dsn['mode'])) {
00241                 $this->dsn['mode'] = 0;
00242             }
00243             $this->connection = @dbase_open($dsn['database'],
00244                                             $this->dsn['mode']);
00245             if (!$this->connection) {
00246                 return $this->raiseError(DB_ERROR_CONNECT_FAILED,
00247                                          null, null, null,
00248                                          $php_errormsg);
00249             }
00250         }
00251         return DB_OK;
00252     }

DB_common::createSequence seq_name  )  [inherited]
 

Creates a new sequence

The name of a given sequence is determined by passing the string provided in the $seq_name argument through PHP's sprintf() function using the value from the seqname_format option as the sprintf()'s format argument.

seqname_format is set via setOption().

Parameters:
string $seq_name name of the new sequence
Returns:
int DB_OK on success. A DB_Error object on failure.
See also:
DB_common::dropSequence(), DB_common::getSequenceName(), DB_common::nextID()

Reimplemented in DB_fbsql, DB_ibase, DB_msql, DB_mssql, DB_mysql, DB_mysqli, DB_oci8, DB_odbc, DB_pgsql, DB_sqlite, and DB_sybase.

Definition at line 1772 of file common.php.

References DB_common::raiseError().

01773     {
01774         return $this->raiseError(DB_ERROR_NOT_CAPABLE);
01775     }

PEAR::delExpect error_code  )  [inherited]
 

This method deletes all occurences of the specified element from the expected error codes stack.

Parameters:
mixed $error_code error code that should be deleted
Returns:
mixed list of error codes that were deleted or error public
Since:
PHP 4.3.0

Definition at line 426 of file PEAR.php.

References PEAR::raiseError().

00427     {
00428         $deleted = false;
00429 
00430         if ((is_array($error_code) && (0 != count($error_code)))) {
00431             // $error_code is a non-empty array here;
00432             // we walk through it trying to unset all
00433             // values
00434             foreach($error_code as $key => $error) {
00435                 if ($this->_checkDelExpect($error)) {
00436                     $deleted =  true;
00437                 } else {
00438                     $deleted = false;
00439                 }
00440             }
00441             return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
00442         } elseif (!empty($error_code)) {
00443             // $error_code comes alone, trying to unset it
00444             if ($this->_checkDelExpect($error_code)) {
00445                 return true;
00446             } else {
00447                 return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
00448             }
00449         } else {
00450             // $error_code is empty
00451             return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
00452         }
00453     }

DB_dbase::disconnect  ) 
 

Disconnects from the database server

Returns:
bool TRUE on success, FALSE on failure

Definition at line 262 of file dbase.php.

00263     {
00264         $ret = @dbase_close($this->connection);
00265         $this->connection = null;
00266         return $ret;
00267     }

DB_common::dropSequence seq_name  )  [inherited]
 

Deletes a sequence

Parameters:
string $seq_name name of the sequence to be deleted
Returns:
int DB_OK on success. A DB_Error object on failure.
See also:
DB_common::createSequence(), DB_common::getSequenceName(), DB_common::nextID()

Reimplemented in DB_fbsql, DB_ibase, DB_msql, DB_mssql, DB_mysql, DB_mysqli, DB_oci8, DB_odbc, DB_pgsql, DB_sqlite, and DB_sybase.

Definition at line 1790 of file common.php.

References DB_common::raiseError().

01791     {
01792         return $this->raiseError(DB_ERROR_NOT_CAPABLE);
01793     }

DB_common::errorCode nativecode  )  [inherited]
 

Maps native error codes to DB's portable ones

Uses the $errorcode_map property defined in each driver.

Parameters:
string|int $nativecode the error code returned by the DBMS
Returns:
int the portable DB error code. Return DB_ERROR if the current driver doesn't have a mapping for the $nativecode submitted.

Reimplemented in DB_ibase, DB_ifx, DB_msql, DB_pgsql, DB_sqlite, and DB_sybase.

Definition at line 1880 of file common.php.

Referenced by DB_fbsql::fbsqlRaiseError(), and DB_odbc::odbcRaiseError().

01881     {
01882         if (isset($this->errorcode_map[$nativecode])) {
01883             return $this->errorcode_map[$nativecode];
01884         }
01885         // Fall back to DB_ERROR if there was no mapping.
01886         return DB_ERROR;
01887     }

DB_common::errorMessage dbcode  )  [inherited]
 

Maps a DB error code to a textual message

Parameters:
integer $dbcode the DB error code
Returns:
string the error message corresponding to the error code submitted. FALSE if the error code is unknown.
See also:
DB::errorMessage()

Definition at line 1902 of file common.php.

References DB::errorMessage().

01903     {
01904         return DB::errorMessage($this->errorcode_map[$dbcode]);
01905     }

DB_common::errorNative  )  [inherited]
 

Gets the DBMS' native error code produced by the last query

Returns:
mixed the DBMS' error code. A DB_Error object on failure.

Reimplemented in DB_fbsql, DB_ibase, DB_ifx, DB_msql, DB_mssql, DB_mysql, DB_mysqli, DB_oci8, DB_odbc, DB_pgsql, DB_sqlite, and DB_sybase.

Definition at line 1861 of file common.php.

References DB_common::raiseError().

01862     {
01863         return $this->raiseError(DB_ERROR_NOT_CAPABLE);
01864     }

DB_common::escapeSimple str  )  [inherited]
 

Escapes a string according to the current DBMS's standards

In SQLite, this makes things safe for inserts/updates, but may cause problems when performing text comparisons against columns containing binary data. See the PHP manual for more info.

Parameters:
string $str the string to be escaped
Returns:
string the escaped string
See also:
DB_common::quoteSmart()
Since:
Method available since Release 1.6.0

Reimplemented in DB_msql, DB_mysql, DB_mysqli, DB_pgsql, and DB_sqlite.

Definition at line 456 of file common.php.

Referenced by quoteSmart(), and DB_common::quoteSmart().

00457     {
00458         return str_replace("'", "''", $str);
00459     }

& DB_common::execute stmt,
data = array()
[inherited]
 

Executes a DB statement prepared with prepare()

Example 1. $sth = $db->prepare('INSERT INTO tbl (a, b, c) VALUES (?, !, &)'); $data = array( "John's text", "'it''s good'", 'filename.txt' ); $res =& $db->execute($sth, $data);

Parameters:
resource $stmt a DB statement resource returned from prepare()
mixed $data array, string or numeric data to be used in execution of the statement. Quantity of items passed must match quantity of placeholders in query: meaning 1 placeholder for non-array parameters or 1 placeholder per array element.
Returns:
mixed a new DB_result object for successful SELECT queries or DB_OK for successul data manipulation queries. A DB_Error object on failure.
{

Reimplemented in DB_ibase, and DB_oci8.

Definition at line 952 of file common.php.

References $result, $tmp, DB_common::executeEmulateQuery(), and DB::isError().

Referenced by DB_common::autoExecute(), DB_common::executeMultiple(), DB_common::getAll(), DB_common::getAssoc(), DB_common::getCol(), DB_common::getOne(), DB_common::getRow(), and DB_common::query().

00953     {
00954         $realquery = $this->executeEmulateQuery($stmt, $data);
00955         if (DB::isError($realquery)) {
00956             return $realquery;
00957         }
00958         $result = $this->simpleQuery($realquery);
00959 
00960         if ($result === DB_OK || DB::isError($result)) {
00961             return $result;
00962         } else {
00963             $tmp =& new DB_result($this, $result);
00964             return $tmp;
00965         }
00966     }

DB_common::executeEmulateQuery stmt,
data = array()
[inherited]
 

Emulates executing prepared statements if the DBMS not support them

Parameters:
resource $stmt a DB statement resource returned from execute()
mixed $data array, string or numeric data to be used in execution of the statement. Quantity of items passed must match quantity of placeholders in query: meaning 1 placeholder for non-array parameters or 1 placeholder per array element.
Returns:
mixed a string containing the real query run when emulating prepare/execute. A DB_Error object on failure.
protected
See also:
DB_common::execute()

Definition at line 987 of file common.php.

References $data, $fp, $i, $value, DB_common::quoteSmart(), and DB_common::raiseError().

Referenced by DB_common::execute().

00988     {
00989         $stmt = (int)$stmt;
00990         $data = (array)$data;
00991         $this->last_parameters = $data;
00992 
00993         if (count($this->prepare_types[$stmt]) != count($data)) {
00994             $this->last_query = $this->prepared_queries[$stmt];
00995             return $this->raiseError(DB_ERROR_MISMATCH);
00996         }
00997 
00998         $realquery = $this->prepare_tokens[$stmt][0];
00999 
01000         $i = 0;
01001         foreach ($data as $value) {
01002             if ($this->prepare_types[$stmt][$i] == DB_PARAM_SCALAR) {
01003                 $realquery .= $this->quoteSmart($value);
01004             } elseif ($this->prepare_types[$stmt][$i] == DB_PARAM_OPAQUE) {
01005                 $fp = @fopen($value, 'rb');
01006                 if (!$fp) {
01007                     return $this->raiseError(DB_ERROR_ACCESS_VIOLATION);
01008                 }
01009                 $realquery .= $this->quoteSmart(fread($fp, filesize($value)));
01010                 fclose($fp);
01011             } else {
01012                 $realquery .= $value;
01013             }
01014 
01015             $realquery .= $this->prepare_tokens[$stmt][++$i];
01016         }
01017 
01018         return $realquery;
01019     }

DB_common::executeMultiple stmt,
data
[inherited]
 

Performs several execute() calls on the same statement handle

$data must be an array indexed numerically from 0, one execute call is done for every "row" in the array.

If an error occurs during execute(), executeMultiple() does not execute the unfinished rows, but rather returns that error.

Parameters:
resource $stmt query handle from prepare()
array $data numeric array containing the data to insert into the query
Returns:
int DB_OK on success. A DB_Error object on failure.
See also:
DB_common::prepare(), DB_common::execute()

Definition at line 1041 of file common.php.

References DB_common::execute(), and DB::isError().

01042     {
01043         foreach ($data as $value) {
01044             $res =& $this->execute($stmt, $value);
01045             if (DB::isError($res)) {
01046                 return $res;
01047             }
01048         }
01049         return DB_OK;
01050     }

PEAR::expectError code = '*'  )  [inherited]
 

This method is used to tell which errors you expect to get. Expected errors are always returned with error mode PEAR_ERROR_RETURN. Expected error codes are stored in a stack, and this method pushes a new element onto it. The list of expected errors are in effect until they are popped off the stack with the popExpect() method.

Note that this method can not be called statically

Parameters:
mixed $code a single error code or an array of error codes to expect
Returns:
int the new depth of the "expected errors" stack public

Definition at line 361 of file PEAR.php.

00362     {
00363         if (is_array($code)) {
00364             array_push($this->_expected_errors, $code);
00365         } else {
00366             array_push($this->_expected_errors, array($code));
00367         }
00368         return sizeof($this->_expected_errors);
00369     }

DB_dbase::fetchInto result,
&$  arr,
fetchmode,
rownum = null
 

Places a row from the result set into the given array

Formating of the array and the data therein are configurable. See DB_result::fetchInto() for more information.

This method is not meant to be called directly. Use DB_result::fetchInto() instead. It can't be declared "protected" because DB_result is a separate object.

Parameters:
resource $result the query result resource
array $arr the referenced array to put the data in
int $fetchmode how the resulting array should be indexed
int $rownum the row number to fetch (0 = first row)
Returns:
mixed DB_OK on success, NULL when the end of a result set is reached or on failure
See also:
DB_result::fetchInto()

Definition at line 303 of file dbase.php.

References $result, DB_common::_convertNullArrayValuesToEmpty(), and DB_common::_rtrimArrayValues().

00304     {
00305         if ($rownum === null) {
00306             $rownum = $this->res_row[(int)$result]++;
00307         }
00308         if ($fetchmode & DB_FETCHMODE_ASSOC) {
00309             $arr = @dbase_get_record_with_names($this->connection, $rownum);
00310             if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE && $arr) {
00311                 $arr = array_change_key_case($arr, CASE_LOWER);
00312             }
00313         } else {
00314             $arr = @dbase_get_record($this->connection, $rownum);
00315         }
00316         if (!$arr) {
00317             return null;
00318         }
00319         if ($this->options['portability'] & DB_PORTABILITY_RTRIM) {
00320             $this->_rtrimArrayValues($arr);
00321         }
00322         if ($this->options['portability'] & DB_PORTABILITY_NULL_TO_EMPTY) {
00323             $this->_convertNullArrayValuesToEmpty($arr);
00324         }
00325         return DB_OK;
00326     }

DB_common::freePrepared stmt,
free_resource = true
[inherited]
 

Frees the internal resources associated with a prepared query

Parameters:
resource $stmt the prepared statement's PHP resource
bool $free_resource should the PHP resource be freed too? Use false if you need to get data from the result set later.
Returns:
bool TRUE on success, FALSE if $result is invalid
See also:
DB_common::prepare()

Reimplemented in DB_ibase, and DB_oci8.

Definition at line 1067 of file common.php.

Referenced by DB_common::autoExecute(), DB_common::getAll(), DB_common::getAssoc(), DB_common::getCol(), DB_common::getOne(), DB_common::getRow(), and DB_common::query().

01068     {
01069         $stmt = (int)$stmt;
01070         if (isset($this->prepare_tokens[$stmt])) {
01071             unset($this->prepare_tokens[$stmt]);
01072             unset($this->prepare_types[$stmt]);
01073             unset($this->prepared_queries[$stmt]);
<