DB_sybase Class Reference

Inheritance diagram for DB_sybase:

Inheritance graph
[legend]
Collaboration diagram for DB_sybase:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DB_sybase ()
 connect ($dsn, $persistent=false)
 disconnect ()
 simpleQuery ($query)
 nextResult ($result)
 fetchInto ($result, &$arr, $fetchmode, $rownum=null)
 freeResult ($result)
 numCols ($result)
 numRows ($result)
 affectedRows ()
 nextId ($seq_name, $ondemand=true)
 createSequence ($seq_name)
 dropSequence ($seq_name)
 autoCommit ($onoff=false)
 commit ()
 rollback ()
 sybaseRaiseError ($errno=null)
 errorNative ()
 errorCode ($errormsg)
 tableInfo ($result, $mode=null)
 _sybase_field_flags ($table, $column)
 _add_flag (&$array, $value)
 getSpecialQuery ($type)
 __sleep ()
 __wakeup ()
 __toString ()
 toString ()
 quoteString ($string)
 quote ($string=null)
 quoteIdentifier ($str)
 quoteSmart ($in)
 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)
 getSequenceName ($sqn)
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)
 errorMessage ($dbcode)
 getTables ()
 getListOf ($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 = 'sybase'
 $dbsyntax = 'sybase'
 $features
 $errorcode_map
 $connection
 $dsn = array()
 $autocommit = true
 $transaction_opcount = 0
 $_db = ''
 $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 52 of file sybase.php.


Constructor & Destructor Documentation

DB_sybase::DB_sybase  ) 
 

This constructor calls $this->DB_common()

Returns:
void

Definition at line 148 of file sybase.php.

References DB_common::DB_common().

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


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     }

DB_sybase::_add_flag &$  array,
value
 

Adds a string to the flags array if the flag is not yet in there

  • if there is no flag present the array is created

Parameters:
array $array reference of flags array to add a value to
mixed $value value to add to the flag array
Returns:
void
private

Definition at line 860 of file sybase.php.

00861     {
00862         if (!is_array($array)) {
00863             $array = array($value);
00864         } elseif (!in_array($value, $array)) {
00865             array_push($array, $value);
00866         }
00867     }

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 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 DB_dbase::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 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 DB_dbase::fetchInto().

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

DB_sybase::_sybase_field_flags table,
column
 

Get the flags for a field

Currently supports: + <samp>unique_key</samp> (unique index, unique check or primary_key) + <samp>multiple_key</samp> (multi-key index)

Parameters:
string $table the table name
string $column the field name
Returns:
string space delimited string of flags. Empty string if none.
private

Definition at line 805 of file sybase.php.

00806     {
00807         static $tableName = null;
00808         static $flags = array();
00809 
00810         if ($table != $tableName) {
00811             $flags = array();
00812             $tableName = $table;
00813 
00814             // get unique/primary keys
00815             $res = $this->getAll("sp_helpindex $table", DB_FETCHMODE_ASSOC);
00816 
00817             if (!isset($res[0]['index_description'])) {
00818                 return '';
00819             }
00820 
00821             foreach ($res as $val) {
00822                 $keys = explode(', ', trim($val['index_keys']));
00823 
00824                 if (sizeof($keys) > 1) {
00825                     foreach ($keys as $key) {
00826                         $this->_add_flag($flags[$key], 'multiple_key');
00827                     }
00828                 }
00829 
00830                 if (strpos($val['index_description'], 'unique')) {
00831                     foreach ($keys as $key) {
00832                         $this->_add_flag($flags[$key], 'unique_key');
00833                     }
00834                 }
00835             }
00836 
00837         }
00838 
00839         if (array_key_exists($column, $flags)) {
00840             return(implode(' ', $flags[$column]));
00841         }
00842 
00843         return '';
00844     }

DB_sybase::affectedRows  ) 
 

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 from DB_common.

Definition at line 436 of file sybase.php.

References $result, and DB::isManip().

00437     {
00438         if (DB::isManip($this->last_query)) {
00439             $result = @sybase_affected_rows($this->connection);
00440         } else {
00441             $result = 0;
00442         }
00443         return $result;
00444      }

DB_sybase::autoCommit onoff = false  ) 
 

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 from DB_common.

Definition at line 542 of file sybase.php.

00543     {
00544         // XXX if $this->transaction_opcount > 0, we should probably
00545         // issue a warning here.
00546         $this->autocommit = $onoff ? true : false;
00547         return DB_OK;
00548     }

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_sybase::commit  ) 
 

Commits the current transaction

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

Reimplemented from DB_common.

Definition at line 558 of file sybase.php.

References $result, and sybaseRaiseError().

00559     {
00560         if ($this->transaction_opcount > 0) {
00561             if (!@sybase_select_db($this->_db, $this->connection)) {
00562                 return $this->sybaseRaiseError(DB_ERROR_NODBSELECTED);
00563             }
00564             $result = @sybase_query('COMMIT', $this->connection);
00565             $this->transaction_opcount = 0;
00566             if (!$result) {
00567                 return $this->sybaseRaiseError();
00568             }
00569         }
00570         return DB_OK;
00571     }

DB_sybase::connect dsn,
persistent = false
 

Connect to the database server, log in and open the database

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

PEAR DB's sybase driver supports the following extra DSN options: + appname The application name to use on this connection. Available since PEAR DB 1.7.0. + charset The character set to use on this connection. Available since PEAR DB 1.7.0.

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 172 of file sybase.php.

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

00173     {
00174         if (!PEAR::loadExtension('sybase') &&
00175             !PEAR::loadExtension('sybase_ct'))
00176         {
00177             return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND);
00178         }
00179 
00180         $this->dsn = $dsn;
00181         if ($dsn['dbsyntax']) {
00182             $this->dbsyntax = $dsn['dbsyntax'];
00183         }
00184 
00185         $dsn['hostspec'] = $dsn['hostspec'] ? $dsn['hostspec'] : 'localhost';
00186         $dsn['password'] = !empty($dsn['password']) ? $dsn['password'] : false;
00187         $dsn['charset'] = isset($dsn['charset']) ? $dsn['charset'] : false;
00188         $dsn['appname'] = isset($dsn['appname']) ? $dsn['appname'] : false;
00189 
00190         $connect_function = $persistent ? 'sybase_pconnect' : 'sybase_connect';
00191 
00192         if ($dsn['username']) {
00193             $this->connection = @$connect_function($dsn['hostspec'],
00194                                                    $dsn['username'],
00195                                                    $dsn['password'],
00196                                                    $dsn['charset'],
00197                                                    $dsn['appname']);
00198         } else {
00199             return $this->raiseError(DB_ERROR_CONNECT_FAILED,
00200                                      null, null, null,
00201                                      'The DSN did not contain a username.');
00202         }
00203 
00204         if (!$this->connection) {
00205             return $this->raiseError(DB_ERROR_CONNECT_FAILED,
00206                                      null, null, null,
00207                                      @sybase_get_last_message());
00208         }
00209 
00210         if ($dsn['database']) {
00211             if (!@sybase_select_db($dsn['database'], $this->connection)) {
00212                 return $this->raiseError(DB_ERROR_NODBSELECTED,
00213                                          null, null, null,
00214                                          @sybase_get_last_message());
00215             }
00216             $this->_db = $dsn['database'];
00217         }
00218 
00219         return DB_OK;
00220     }

DB_sybase::createSequence seq_name  ) 
 

Creates a new sequence

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::createSequence(), DB_common::getSequenceName(), DB_sybase::nextID(), DB_sybase::dropSequence()

Reimplemented from DB_common.

Definition at line 505 of file sybase.php.

References DB_common::query().

Referenced by nextId().

00506     {
00507         return $this->query('CREATE TABLE '
00508                             . $this->getSequenceName($seq_name)
00509                             . ' (id numeric(10, 0) IDENTITY NOT NULL,'
00510                             . ' vapor int NULL)');
00511     }

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_sybase::disconnect  ) 
 

Disconnects from the database server

Returns:
bool TRUE on success, FALSE on failure

Definition at line 230 of file sybase.php.

00231     {
00232         $ret = @sybase_close($this->connection);
00233         $this->connection = null;
00234         return $ret;
00235     }

DB_sybase::dropSequence seq_name  ) 
 

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::dropSequence(), DB_common::getSequenceName(), DB_sybase::nextID(), DB_sybase::createSequence()

Reimplemented from DB_common.

Definition at line 526 of file sybase.php.

References DB_common::query().

00527     {
00528         return $this->query('DROP TABLE ' . $this->getSequenceName($seq_name));
00529     }

DB_sybase::errorCode errormsg  ) 
 

Determines PEAR::DB error code from the database's text error message.

Parameters:
string $errormsg error message returned from the database
Returns:
integer an error number from a DB error constant

Reimplemented from DB_common.

Definition at line 642 of file sybase.php.

References DB_common::quote().

Referenced by sybaseRaiseError().

00643     {
00644         static $error_regexps;
00645         if (!isset($error_regexps)) {
00646             $error_regexps = array(
00647                 '/Incorrect syntax near/'
00648                     => DB_ERROR_SYNTAX,
00649                 '/^Unclosed quote before the character string [\"\'].*[\"\']\./'
00650                     => DB_ERROR_SYNTAX,
00651                 '/Implicit conversion (from datatype|of NUMERIC value)/i'
00652                     => DB_ERROR_INVALID_NUMBER,
00653                 '/Cannot drop the table [\"\'].+[\"\'], because it doesn\'t exist in the system catalogs\./'
00654                     => DB_ERROR_NOSUCHTABLE,
00655                 '/Only the owner of object [\"\'].+[\"\'] or a user with System Administrator \(SA\) role can run this command\./'
00656                     => DB_ERROR_ACCESS_VIOLATION,
00657                 '/^.+ permission denied on object .+, database .+, owner .+/'
00658                     => DB_ERROR_ACCESS_VIOLATION,
00659                 '/^.* permission denied, database .+, owner .+/'
00660                     => DB_ERROR_ACCESS_VIOLATION,
00661                 '/[^.*] not found\./'
00662                     => DB_ERROR_NOSUCHTABLE,
00663                 '/There is already an object named/'
00664                     => DB_ERROR_ALREADY_EXISTS,
00665                 '/Invalid column name/'
00666                     => DB_ERROR_NOSUCHFIELD,
00667                 '/does not allow null values/'
00668                     => DB_ERROR_CONSTRAINT_NOT_NULL,
00669                 '/Command has been aborted/'
00670                     => DB_ERROR_CONSTRAINT,
00671                 '/^Cannot drop the index .* because it doesn\'t exist/i'
00672                     => DB_ERROR_NOT_FOUND,
00673                 '/^There is already an index/i'
00674                     => DB_ERROR_ALREADY_EXISTS,
00675                 '/^There are fewer columns in the INSERT statement than values specified/i'
00676                     => DB_ERROR_VALUE_COUNT_ON_ROW,
00677             );
00678         }
00679 
00680         foreach ($error_regexps as $regexp => $code) {
00681             if (preg_match($regexp, $errormsg)) {
00682                 return $code;
00683             }
00684         }
00685         return DB_ERROR;
00686     }

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_sybase::errorNative  ) 
 

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

Returns:
string the DBMS' error message

Reimplemented from DB_common.

Definition at line 628 of file sybase.php.

Referenced by sybaseRaiseError().

00629     {
00630         return @sybase_get_last_message();
00631     }

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 DB_dbase::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_sybase::fetchInto result,