Class DB_sqlite

Description

Database independent query interface definition for the SQLite PECL extension.

Located in /maintenance/libraries/pear/DB/sqlite.php (line 35)

PEAR
   |
   --DB_common
      |
      --DB_sqlite
Variable Summary
Method Summary
 DB_sqlite DB_sqlite ()
 number affectedRows ()
 int connect ($dsn $dsninfo, [$persistent $persistent = false])
 int createSequence (string $seq_name)
 bool disconnect ()
 int dropSequence (string $seq_name)
 integer errorCode (string $errormsg)
 string errorNative ()
 string escapeSimple (string $str)
 mixed fetchInto (resource $result, array &$arr, int $fetchmode, [int $rownum = null])
 bool freeResult ($result &$result)
 mixed getDbFileStats ([string $arg = ''])
 string getSpecialQuery (string $type, [mixed $args = array()])
 void modifyLimitQuery (mixed $query, mixed $from, mixed $count, [mixed $params = array()])
 int nextId (string $seq_name, [boolean $ondemand = true])
 true nextResult (a $result)
 number numCols (mixed $result)
 number numRows (mixed $result)
 mixed simpleQuery (the $query)
 object DB sqliteRaiseError ([integer $errno = null])
 string _modifyQuery (string $query)
Variables
mixed $connection (line 39)
mixed $dbsyntax (line 40)
mixed $phptype (line 40)

Redefinition of:
DB_common::$phptype
DB type (mysql, oci8, odbc etc.)
mixed $prepare_tokens = array() (line 41)

Redefinition of:
DB_common::$prepare_tokens
mixed $prepare_types = array() (line 42)

Redefinition of:
DB_common::$prepare_types
mixed $_lasterror = '' (line 43)

Inherited Variables

Inherited from DB_common

DB_common::$dbh
DB_common::$errorcode_map
DB_common::$features
DB_common::$fetchmode
DB_common::$fetchmode_object_class
DB_common::$last_query
DB_common::$options
DB_common::$prepared_queries
DB_common::$prepare_maxstmt
Methods
Constructor DB_sqlite (line 58)

Constructor for this class.

Error codes according to sqlite_exec. Error Codes specification is in the online manual.

This errorhandling based on sqlite_exec is not yet implemented.

  • access: public
DB_sqlite DB_sqlite ()
affectedRows (line 342)

Gets the number of rows affected by a query.

  • return: of rows affected by the last query
number affectedRows ()

Redefinition of:
DB_common::affectedRows()
Returns the affected rows of a query
connect (line 107)

Connect to a database represented by a file.

  • return: DB_OK on success, a DB error on failure
  • access: public
int connect ($dsn $dsninfo, [$persistent $persistent = false])
  • $dsn $dsninfo: the data source name; the file is taken as database; "sqlite://root:@host/test.db?mode=0644"
  • $persistent $persistent: (optional) whether the connection should be persistent
createSequence (line 429)

Creates a new sequence

int createSequence (string $seq_name)
  • string $seq_name: name of the new sequence

Redefinition of:
DB_common::createSequence()
Creates a new sequence
disconnect (line 163)

Log out and disconnect from the database.

  • return: true on success, false if not connected.
  • todo: fix return values
  • access: public
bool disconnect ()
dropSequence (line 411)

Deletes a sequence

int dropSequence (string $seq_name)
  • string $seq_name: name of the sequence to be deleted

Redefinition of:
DB_common::dropSequence()
Deletes a sequence
errorCode (line 373)

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

  • return: an error number from a DB error constant
integer errorCode (string $errormsg)
  • string $errormsg: error message returned from the database

Redefinition of:
DB_common::errorCode()
Map native error codes to DB's portable ones
errorNative (line 359)

Get the native error string of the last error (if any) that occured on the current connection.

This is used to retrieve more meaningfull error messages DB_pgsql way since sqlite_last_error() does not provide adequate info.

  • return: native SQLite error message
string errorNative ()

Redefinition of:
DB_common::errorNative()
Returns an errormessage, provides by the database
escapeSimple (line 622)

Escape 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.

string escapeSimple (string $str)
  • string $str: the string to be escaped

Redefinition of:
DB_common::escapeSimple()
Escape a string according to the current DBMS's standards
fetchInto (line 247)

Fetch a row and insert the data into an existing array.

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

  • return: DB_OK on success, null when end of result set is reached or on failure
  • access: private
  • see: DB_result::fetchInto()
mixed fetchInto (resource $result, array &$arr, int $fetchmode, [int $rownum = null])
  • resource $result: query result identifier
  • array $arr: (reference) array where data from the row should be placed
  • int $fetchmode: how the resulting array should be indexed
  • int $rownum: the row number to fetch
freeResult (line 290)

Free the internal resources associated with $result.

  • return: true on success, false if $result is invalid
  • access: public
bool freeResult ($result &$result)
  • $result &$result: SQLite result identifier
getDbFileStats (line 583)

Get the file stats for the current database.

Possible arguments are dev, ino, mode, nlink, uid, gid, rdev, size, atime, mtime, ctime, blksize, blocks or a numeric key between

  1. and 12.

  • return: array on an unspecified key, integer on a passed arg and false at a stats error.
mixed getDbFileStats ([string $arg = ''])
  • string $arg: Array key for stats()
getSpecialQuery (line 504)

Returns the query needed to get some backend info.

Refer to the online manual at http://sqlite.org/sqlite.html.

  • return: The SQL query string
string getSpecialQuery (string $type, [mixed $args = array()])
  • string $type: What kind of info you want to retrieve

Redefinition of:
DB_common::getSpecialQuery()
Returns the query needed to get some backend info
modifyLimitQuery (line 629)
void modifyLimitQuery (mixed $query, mixed $from, mixed $count, [mixed $params = array()])

Redefinition of:
DB_common::modifyLimitQuery()
This method is used by backends to alter limited queries
nextId (line 464)

Returns the next free id in a sequence

  • return: the next id number in the sequence. DB_Error if problem.
  • access: public
  • see: DB_common::nextID()
  • internal:
int nextId (string $seq_name, [boolean $ondemand = true])
  • string $seq_name: name of the sequence
  • boolean $ondemand: when true, the seqence is automatically created if it does not exist

Redefinition of:
DB_common::nextId()
Returns the next free id in a sequence
nextResult (line 221)

Move the internal sqlite result pointer to the next available result.

  • return: if a result is available otherwise return false
  • access: public
true nextResult (a $result)
  • a $result: valid sqlite result resource
numCols (line 308)

Gets the number of columns in a result set.

  • return: of columns in a result set
number numCols (mixed $result)
numRows (line 325)

Gets the number of rows affected by a query.

  • return: of rows affected by the last query
number numRows (mixed $result)

Redefinition of:
DB_common::numRows()
Returns the number of rows in a result object
simpleQuery (line 183)

Send a query to SQLite and returns the results as a SQLite resource identifier.

  • return: returns a valid SQLite result for successful SELECT queries, DB_OK for other successful queries. A DB error is returned on failure.
  • access: public
mixed simpleQuery (the $query)
  • the $query: SQL query
sqliteRaiseError (line 671)

Gather information about an error, then use that info to create a DB error object and finally return that object.

object DB sqliteRaiseError ([integer $errno = null])
  • integer $errno: PEAR error number (usually a DB constant) if manually raising an error
_modifyQuery (line 646)

"DELETE FROM table" gives 0 affected rows in SQLite.

This little hack lets you know how many rows were deleted.

  • return: The SQL query string
string _modifyQuery (string $query)
  • string $query: The SQL query string

Inherited Methods

Inherited From DB_common

 DB_common::DB_common()
 DB_common::affectedRows()
 DB_common::autoCommit()
 DB_common::autoExecute()
 DB_common::autoPrepare()
 DB_common::buildManipSQL()
 DB_common::commit()
 DB_common::createSequence()
 DB_common::dropSequence()
 DB_common::errorCode()
 DB_common::errorMessage()
 DB_common::errorNative()
 DB_common::escapeSimple()
 DB_common::execute()
 DB_common::executeEmulateQuery()
 DB_common::executeMultiple()
 DB_common::freePrepared()
 DB_common::getAll()
 DB_common::getAssoc()
 DB_common::getCol()
 DB_common::getListOf()
 DB_common::getOne()
 DB_common::getOption()
 DB_common::getRow()
 DB_common::getSequenceName()
 DB_common::getSpecialQuery()
 DB_common::getTables()
 DB_common::limitQuery()
 DB_common::modifyLimitQuery()
 DB_common::modifyQuery()
 DB_common::nextId()
 DB_common::numRows()
 DB_common::prepare()
 DB_common::provides()
 DB_common::query()
 DB_common::quote()
 DB_common::quoteIdentifier()
 DB_common::quoteSmart()
 DB_common::quoteString()
 DB_common::raiseError()
 DB_common::rollback()
 DB_common::setFetchMode()
 DB_common::setOption()
 DB_common::tableInfo()
 DB_common::toString()
 DB_common::_convertNullArrayValuesToEmpty()
 DB_common::_rtrimArrayValues()

Documentation generated on Fri, 24 Dec 2004 13:03:28 +0000 by phpDocumentor 1.3.0RC3