PHP Class Habari\SQLiteConnection

Inheritance: extends DatabaseConnection
Show file Open project: habari/system

Public Methods

Method Description
connect ( $connect_string, $db_user, $db_pass ) : boolean Connect to SQLite Overrides the DatabaseConnection to return false if the SQLite file doesn't exist.
dbdelta ( $queries, $execute = true, $silent = true, $doinserts = false ) : string automatic diffing function - used for determining required database upgrades based on Owen Winkler's microwiki upgrade function
execute_procedure ( $procedure, $args = [] ) : mixed Execute a stored procedure
replace_concat ( array $matches ) : string Replaces the MySQL CONCAT function with SQLite-compatible statements
sql_t ( string $sql, array &$args ) : string database specific SQL translation function, loosely modelled on the internationalization _t() function Call with a database independent SQL string and it will be translated to a SQLite specific SQL string
upgrade_post ( integer $old_version, $upgrade_path = '' ) : boolean Run all of the upgrades slated for post-dbdelta since the last database revision.
upgrade_pre ( integer $old_version, $upgrade_path = '' ) : boolean Run all of the upgrades slated for pre-dbdelta since the last database revision.

Protected Methods

Method Description
filter_fieldnames ( StdClass $row ) : string Filter out the fieldnames from whole pragma rows

Method Details

connect() public method

Connect to SQLite Overrides the DatabaseConnection to return false if the SQLite file doesn't exist.
public connect ( $connect_string, $db_user, $db_pass ) : boolean
return boolean True if connection succeeded, false if not.

dbdelta() public method

automatic diffing function - used for determining required database upgrades based on Owen Winkler's microwiki upgrade function
public dbdelta ( $queries, $execute = true, $silent = true, $doinserts = false ) : string
return string translated SQL string

execute_procedure() public method

Execute a stored procedure
public execute_procedure ( $procedure, $args = [] ) : mixed
return mixed whatever the procedure returns... Not supported with SQLite

filter_fieldnames() protected method

Filter out the fieldnames from whole pragma rows
protected filter_fieldnames ( StdClass $row ) : string
$row StdClass A row result from a SQLite PRAGMA table_info query
return string The name of the associated field

replace_concat() public method

Replaces the MySQL CONCAT function with SQLite-compatible statements
See also: SQLiteConnection::sql_t()
public replace_concat ( array $matches ) : string
$matches array Matches from the regex in sql_t()
return string The replacement for the MySQL SQL

sql_t() public method

database specific SQL translation function, loosely modelled on the internationalization _t() function Call with a database independent SQL string and it will be translated to a SQLite specific SQL string
public sql_t ( string $sql, array &$args ) : string
$sql string database independent SQL
$args array An array of SQL arguments
return string translated SQL string

upgrade_post() public method

Run all of the upgrades slated for post-dbdelta since the last database revision.
public upgrade_post ( integer $old_version, $upgrade_path = '' ) : boolean
$old_version integer The current version of the database that is being upgraded
return boolean True on success

upgrade_pre() public method

Run all of the upgrades slated for pre-dbdelta since the last database revision.
public upgrade_pre ( integer $old_version, $upgrade_path = '' ) : boolean
$old_version integer The current version of the database that is being upgraded
return boolean True on success