Source for file sqlite.php
Documentation is available at sqlite.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
* @package Joomla.Platform
* @see http://php.net/pdo
* The name of the database driver.
* The character(s) used to quote SQL statement names such as table names or field names,
* etc. The child classes should define this as necessary. If a single character string the
* same character is used for both sides of the quoted name, else the first character will be
* used for the opening quote and the second for the closing quote.
* Disconnects the database.
* Drops a table from the database.
* @param string $tableName The name of the database table to drop.
* @param boolean $ifExists Optionally specify that the table must exist before it is dropped.
* @return JDatabaseDriverSqlite Returns this object to support chaining.
public function dropTable($tableName, $ifExists =
true)
$this->setQuery('DROP TABLE ' .
($ifExists ?
'IF EXISTS ' :
'') .
$query->quoteName($tableName));
* Method to escape a string for usage in an SQLite statement.
* Note: Using query objects with bound variables is
* preferable to the below.
* @param string $text The string to be escaped.
* @param boolean $extra Unused optional parameter to provide extra escaping.
* @return string The escaped string.
public function escape($text, $extra =
false)
return SQLite3::escapeString($text);
* Method to get the database collation in use by sampling a text field of a table in the database.
* @return mixed The collation in use by the database or boolean false if not supported.
* Shows the table CREATE statement that creates the given tables.
* Note: Doesn't appear to have support in SQLite
* @param mixed $tables A table name or a list of table names.
* @return array A list of the create SQL for the tables.
* @throws RuntimeException
// Sanitize input to an array and iterate over the list.
* Retrieves field information about a given table.
* @param string $table The name of the database table.
* @param boolean $typeOnly True to only return field types.
* @return array An array of fields for the database table.
* @throws RuntimeException
$fieldCasing =
$this->getOption(PDO::ATTR_CASE);
$this->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);
$query->setQuery('pragma table_info(' .
$table .
')');
foreach ($fields as $field)
$columns[$field->NAME] =
$field->TYPE;
foreach ($fields as $field)
// Do some dirty translation to MySQL output.
// TODO: Come up with and implement a standard across databases.
$columns[$field->NAME] = (object)
array(
'Null' =>
($field->NOTNULL ==
'1' ?
'NO' :
'YES'),
'Default' =>
$field->DFLT_VALUE,
'Key' =>
($field->PK ==
'1' ?
'PRI' :
'')
$this->setOption(PDO::ATTR_CASE, $fieldCasing);
* Get the details list of keys for a table.
* @param string $table The name of the table.
* @return array An array of the column specification for the table.
* @throws RuntimeException
$fieldCasing =
$this->getOption(PDO::ATTR_CASE);
$this->setOption(PDO::ATTR_CASE, PDO::CASE_UPPER);
$query->setQuery('pragma table_info( ' .
$table .
')');
// $query->bind(':tableName', $table);
foreach ($rows as $column)
$keys[$column->NAME] =
$column;
$this->setOption(PDO::ATTR_CASE, $fieldCasing);
* Method to get an array of all tables in the database (schema).
* @return array An array of all the tables in the database.
* @throws RuntimeException
* Get the version of the database connector.
* @return string The database connector version.
$this->setQuery("SELECT sqlite_version()");
* Select a database for use.
* @param string $database The name of the database to select for use.
* @return boolean True if the database was successfully selected.
* @throws RuntimeException
public function select($database)
* Set the connection to use UTF-8 character encoding.
* Returns false automatically for the Oracle driver since
* you can only set the character set when the connection
* @return boolean True on success.
* Locks a table in the database.
* @param string $table The name of the table to unlock.
* @return JDatabaseDriverSqlite Returns this object to support chaining.
* @throws RuntimeException
* Renames a table in the database.
* @param string $oldTable The name of the table to be renamed
* @param string $newTable The new name for the table.
* @param string $backup Not used by Sqlite.
* @param string $prefix Not used by Sqlite.
* @return JDatabaseDriverSqlite Returns this object to support chaining.
* @throws RuntimeException
public function renameTable($oldTable, $newTable, $backup =
null, $prefix =
null)
$this->setQuery('ALTER TABLE ' .
$oldTable .
' RENAME TO ' .
$newTable)->execute();
* Unlocks tables in the database.
* @return JDatabaseDriverSqlite Returns this object to support chaining.
* @throws RuntimeException
* Test to see if the PDO ODBC connector is available.
* @return boolean True on success, false otherwise.
* Method to commit a transaction.
* @param boolean $toSavepoint If true, commit to the last savepoint.
* @throws RuntimeException
* Method to roll back a transaction.
* @param boolean $toSavepoint If true, rollback to the last savepoint.
* @throws RuntimeException
* Method to initialize a transaction.
* @param boolean $asSavepoint If true and a transaction is already active, a savepoint will be created.
* @throws RuntimeException
Documentation generated on Tue, 19 Nov 2013 15:14:08 +0100 by phpDocumentor 1.4.3