Class DB_sqlite

Description

The methods PEAR DB uses to interact with PHP's sqlite extension for interacting with SQLite databases

These methods overload the ones declared in DB_common.

NOTICE: This driver needs PHP's track_errors ini setting to be on. It is automatically turned on when connecting to the database. Make sure your scripts don't turn it off.

Located in /web/lib/external/pear-db/DB/sqlite.php (line 53)

PEAR
   |
   --DB_common
      |
      --DB_sqlite
Variable Summary
 resource $connection
 string $dbsyntax
 array $dsn
 array $features
 array $keywords
 string $phptype
Method Summary
 void DB_sqlite ()
 int affectedRows ()
 int connect (array $dsn, [bool $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,  &$arr, int $fetchmode, [int $rownum = null], array $arr)
 bool freeResult ( &$result, resource $result)
 mixed getDbFileStats ([string $arg = ''])
 string getSpecialQuery (string $type, [array $args = array()])
 string modifyLimitQuery (string $query, int $from, int $count, [mixed $params = array()])
 string modifyQuery (string $query)
 int nextId (string $seq_name, [boolean $ondemand = true])
 bool nextResult (resource $result)
 int numCols (resource $result)
 int numRows (resource $result)
 mixed simpleQuery (string $query)
 object the sqliteRaiseError ([int $errno = null])
 array tableInfo (string $result, [int $mode = null])
Variables
resource $connection (line 108)

The raw database connection created by PHP

string $dbsyntax = 'sqlite' (line 67)

The database syntax variant to be used (db2, access, etc.), if any

array $dsn = array() (line 114)

The DSN information for connecting to a database

array $errorcode_map = array(
)
(line 101)

A mapping of native error codes to DB error codes

array $features = array(
'limit' => 'alter',
'new_link' => false,
'numrows' => true,
'pconnect' => true,
'prepare' => false,
'ssl' => false,
'transactions' => false,
)
(line 82)

The capabilities of this DB implementation

The 'new_link' element contains the PHP version that first provided new_link support for this DBMS. Contains false if it's unsupported.

Meaning of the 'limit' element:

  • 'emulate' = emulate with fetch row by number
  • 'alter' = alter the query
  • false = skip rows

array $keywords = array (
'BLOB' => '',
'BOOLEAN' => '',
'CHARACTER' => '',
'CLOB' => '',
'FLOAT' => '',
'INTEGER' => '',
'KEY' => '',
'NATIONAL' => '',
'NUMERIC' => '',
'NVARCHAR' => '',
'PRIMARY' => '',
'TEXT' => '',
'TIMESTAMP' => '',
'UNIQUE' => '',
'VARCHAR' => '',
'VARYING' => '',
)
(line 124)

SQLite data types

string $phptype = 'sqlite' (line 61)

The DB driver type (mysql, oci8, odbc, etc.)

Inherited Variables

Inherited from DB_common

DB_common::$fetchmode
DB_common::$fetchmode_object_class
DB_common::$last_parameters
DB_common::$last_query
DB_common::$options
DB_common::$prepared_queries
DB_common::$prepare_tokens
DB_common::$prepare_types
DB_common::$was_connected
DB_common::$_last_query_manip
DB_common::$_next_query_manip
Methods
Constructor DB_sqlite (line 159)

This constructor calls $this->DB_common()

void DB_sqlite ()
affectedRows (line 478)

Determines the number of rows affected by a data maniuplation query

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

  • return: the number of rows. A DB_Error object on failure.
int affectedRows ()

Redefinition of:
DB_common::affectedRows()
Determines the number of rows affected by a data maniuplation query
connect (line 196)

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

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

PEAR DB's sqlite driver supports the following extra DSN options:

  • mode The permissions for the database file, in four digit chmod octal format (eg "0600").
Example of connecting to a database in read-only mode:
  1.  require_once 'DB.php';
  2.  
  3.  $dsn 'sqlite:///path/and/name/of/db/file?mode=0400';
  4.  $options array(
  5.      'portability' => DB_PORTABILITY_ALL,
  6.  );
  7.  
  8.  $db DB::connect($dsn$options);
  9.  if (PEAR::isError($db)) {
  10.      die($db->getMessage());
  11.  }

  • return: DB_OK on success. A DB_Error object on failure.
int connect (array $dsn, [bool $persistent = false])
  • array $dsn: the data source name
  • bool $persistent: should the connection be persistent?
createSequence (line 511)

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 260)

Disconnects from the database server

  • return: TRUE on success, FALSE on failure
bool disconnect ()
dropSequence (line 496)

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 739)

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

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

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

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

  • return: the DBMS' error message
string errorNative ()

Redefinition of:
DB_common::errorNative()
Gets the DBMS' native error code produced by the last query
escapeSimple (line 628)

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.

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

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

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.

  • return: DB_OK on success, NULL when the end of a result set is reached or on failure
  • see: DB_result::fetchInto()
mixed fetchInto (resource $result,  &$arr, int $fetchmode, [int $rownum = null], array $arr)
  • 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)
  • &$arr
freeResult (line 408)

Deletes the result set and frees the memory occupied by the result set

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

bool freeResult ( &$result, resource $result)
  • resource $result: PHP's query result resource
  • &$result
getDbFileStats (line 590)

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: an array on an unspecified key, integer on a passed arg and false at a stats error
mixed getDbFileStats ([string $arg = ''])
  • string $arg: the array key for stats()
getSpecialQuery (line 876)

Obtains the query string needed for listing a given type of objects

  • return: the SQL query string or null if the driver doesn't support the object type requested
  • see: DB_common::getListOf()
  • access: protected
string getSpecialQuery (string $type, [array $args = array()])
  • string $type: the kind of objects you want to retrieve
  • array $args: SQLITE DRIVER ONLY: a private array of arguments used by the getSpecialQuery(). Do not use this directly.

Redefinition of:
DB_common::getSpecialQuery()
Obtains the query string needed for listing a given type of objects
modifyLimitQuery (line 652)

Adds LIMIT clauses to a query string according to current DBMS standards

  • return: the query string with LIMIT clauses added
  • access: protected
string modifyLimitQuery (string $query, int $from, int $count, [mixed $params = array()])
  • string $query: the query to modify
  • int $from: the row to start to fetching (0 = the first row)
  • int $count: the numbers of rows to fetch
  • mixed $params: 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.

Redefinition of:
DB_common::modifyLimitQuery()
Adds LIMIT clauses to a query string according to current DBMS standards
modifyQuery (line 674)

Changes a query string for various DBMS specific reasons

This little hack lets you know how many rows were deleted when running a "DELETE FROM table" query. Only implemented if the DB_PORTABILITY_DELETE_COUNT portability option is on.

string modifyQuery (string $query)
  • string $query: the query string to modify

Redefinition of:
DB_common::modifyQuery()
Changes a query string for various DBMS specific reasons
nextId (line 546)

Returns the next free id in a sequence

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 322)

Move the internal sqlite result pointer to the next available result

  • return: true if a result is available otherwise return false
bool nextResult (resource $result)
  • resource $result: the valid sqlite result resource
numCols (line 434)

Gets the number of columns in a result set

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

int numCols (resource $result)
  • resource $result: PHP's query result resource
numRows (line 459)

Gets the number of rows in a result set

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

int numRows (resource $result)
  • resource $result: PHP's query result resource

Redefinition of:
DB_common::numRows()
Determines the number of rows in a query result
simpleQuery (line 283)

Sends a query to the database server

NOTICE: This method needs PHP's track_errors ini setting to be on. It is automatically turned on when connecting to the database. Make sure your scripts don't turn it off.

  • return: + a PHP result resrouce for successful SELECT queries
    • the DB_OK constant for other successful queries
    • a DB_Error object on failure
mixed simpleQuery (string $query)
  • string $query: the SQL query string
sqliteRaiseError (line 700)

Produces a DB_Error object regarding the current problem

object the sqliteRaiseError ([int $errno = null])
  • int $errno: if the error is being manually raised pass a DB_ERROR* constant here. If this isn't passed the error information gathered from the DBMS.
tableInfo (line 787)

Returns information about a table

  • return: an associative array with the information requested. A DB_Error object on failure.
  • see: DB_common::tableInfo()
  • since: Method available since Release 1.7.0
array tableInfo (string $result, [int $mode = null])
  • string $result: a string containing the name of a table
  • int $mode: a valid tableInfo mode

Redefinition of:
DB_common::tableInfo()
Returns information about a table or a result set

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::nextQueryIsManip()
 DB_common::numRows()
 DB_common::prepare()
 DB_common::provides()
 DB_common::query()
 DB_common::quote()
 DB_common::quoteBoolean()
 DB_common::quoteFloat()
 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::_checkManip()
 DB_common::_convertNullArrayValuesToEmpty()
 DB_common::_rtrimArrayValues()
 DB_common::__sleep()
 DB_common::__toString()
 DB_common::__wakeup()

Inherited From PEAR

 PEAR::PEAR()
 PEAR::delExpect()
 PEAR::expectError()
 PEAR::getStaticProperty()
 PEAR::isError()
 PEAR::loadExtension()
 PEAR::popErrorHandling()
 PEAR::popExpect()
 PEAR::pushErrorHandling()
 PEAR::raiseError()
 PEAR::registerShutdownFunc()
 PEAR::setErrorHandling()
 PEAR::staticPopErrorHandling()
 PEAR::staticPushErrorHandling()
 PEAR::throwError()
 PEAR::_PEAR()

Documentation generated on Wed, 09 Feb 2011 09:04:41 +0700 by phpDocumentor 1.4.2