PHP Class CI_DB_driver, TastyIgniter

This is the platform-independent base DB implementation class. This class will not be called directly. Rather, the adapter class for the specific database will extend and instantiate it.
Author: ExpressionEngine Dev Team
Afficher le fichier Open project: tastyigniter/tastyigniter Class Usage Examples

Méthodes publiques

Свойство Type Description
$CACHE object DB Cache object
$benchmark integer Benchmark time
$bind_marker string Character used to identify values in a prepared statement.
$cache_autodel boolean Cache auto-delete flag
$cache_on boolean Cache On flag
$cachedir boolean Cache directory path
$char_set string Character set
$conn_id object | resource Connection ID
$data_cache array An internal generic value cache.
$database string Database name
$db_debug boolean Whether to display error messages.
$dbcollat string Collation
$dbdriver string Database driver
$dbprefix string Table prefix
$dsn string Data Source Name / Connect string
$encrypt mixed Encryption flag/data
$hostname string Hostname
$password string Password
$pconnect boolean Persistent connection flag
$port integer Database port
$queries string[] Queries list
$query_count integer Executed queries count
$query_times array A list of times that queries took to execute.
$result_id object | resource Result ID
$save_queries boolean Whether to keep an in-memory history of queries for debugging purposes.
$subdriver string Sub-driver
$swap_pre string Swap Prefix
$trans_enabled boolean Transaction enabled flag
$trans_strict boolean Strict transaction mode flag
$username string Username

Protected Properties

Свойство Type Description
$_count_string string COUNT string
$_escape_char string Identifier escape character
$_like_escape_chr string ESCAPE character
$_like_escape_str string ESCAPE statement string
$_protect_identifiers boolean Protect identifiers flag
$_random_keyword array ORDER BY random keyword
$_reserved_identifiers string[] Identifiers that must NOT be escaped.
$_trans_depth integer Transaction depth level
$_trans_failure boolean Used with transactions to determine if a transaction has failed.
$_trans_status boolean Used with transactions to determine if a rollback should occur.

Méthodes publiques

Méthode Description
__construct ( array $params ) : void Class constructor
cache_delete ( string $segment_one = '', string $segment_two = '' ) : boolean Delete the cache files associated with a particular URI
cache_delete_all ( ) : boolean Delete All cache files
cache_off ( ) : boolean Disable Query Caching
cache_on ( ) : boolean Enable Query Caching
cache_set_path ( $path = '' ) : void Set Cache Directory Path
call_function ( string $function ) : mixed Enables a native PHP function to be run, using a platform agnostic wrapper.
close ( ) : void Close DB Connection
compile_binds ( $sql, $binds ) : string Compile Bindings
count_all ( $table = '' ) : integer "Count All" query
db_connect ( ) : mixed DB connect
db_pconnect ( ) : mixed Persistent database connection
db_select ( ) : boolean Select database
db_set_charset ( $charset ) : boolean Set client character set
display_error ( $error = '', $swap = '', $native = FALSE ) : string Display an error message
elapsed_time ( $decimals = 6 ) : string Calculate the aggregate query elapsed time
error ( ) : array Last error
escape ( $str ) : mixed "Smart" Escape String
escape_identifiers ( $item ) : mixed Escape the SQL Identifiers
escape_like_str ( $str ) : mixed Escape LIKE String
escape_str ( string | string[] $str, boolean $like = FALSE ) : string Escape String
field_data ( string $table ) : array Returns an object with field data
field_exists ( $field_name, $table_name ) : boolean Determine if a particular field exists
initialize ( ) : boolean Initialize Database Settings
insert_string ( $table, $data ) : string Generate an insert string
is_write_type ( $sql ) : boolean Determines if a query is a "write" type.
last_query ( ) : string Returns the last query that was executed
list_fields ( string $table ) : array Fetch Field Names
list_tables ( string $constrain_by_prefix = FALSE ) : array Returns an array of table names
load_rdriver ( ) : string Load the result drivers
platform ( ) : string The name of the platform in use (mysql, mssql, etc.
primary ( string $table ) : string Primary
protect_identifiers ( $item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE ) : string Protect Identifiers
query ( string $sql, array $binds = FALSE, boolean $return_object = NULL ) : mixed Execute the query
reconnect ( ) : void Reconnect
simple_query ( $sql ) : mixed Simple Query This is a simplified version of the query() function. Internally we only use it when running transaction commands since they do not require all the features of the main query() function.
table_exists ( string $table_name ) : boolean Determine if a particular table exists
total_queries ( ) : integer Returns the total number of queries
trans_begin ( boolean $test_mode = FALSE ) : boolean Begin Transaction
trans_commit ( ) : boolean Commit Transaction
trans_complete ( ) : boolean Complete Transaction
trans_off ( ) : void Disable Transactions This permits transactions to be disabled at run-time.
trans_rollback ( ) : boolean Rollback Transaction
trans_start ( boolean $test_mode = FALSE ) : boolean Start Transaction
trans_status ( ) : boolean Lets you retrieve the transaction flag to determine if it has failed
trans_strict ( boolean $mode = TRUE ) : void Enable/disable Transaction Strict Mode
update_string ( $table, $data, $where ) : string Generate an update string
version ( ) : string Database version number

Méthodes protégées

Méthode Description
_cache_init ( ) : boolean Initialize the Cache Class
_close ( ) : void Close DB Connection
_escape_str ( $str ) : string Platform-dependant string escape
_get_operator ( $str ) : string Returns the SQL string operator
_has_operator ( $str ) : boolean Tests whether the string has an SQL operator
_insert ( $table, $keys, $values ) : string Insert statement
_reset_select ( ) : void Dummy method that allows Query Builder class to be disabled and keep count_all() working.
_update ( $table, $values ) : string Update statement
_version ( ) : string Version number query string

Method Details

__construct() public méthode

Class constructor
public __construct ( array $params ) : void
$params array
Résultat void

_cache_init() protected méthode

Initialize the Cache Class
protected _cache_init ( ) : boolean
Résultat boolean

_close() protected méthode

This method would be overridden by most of the drivers.
protected _close ( ) : void
Résultat void

_escape_str() protected méthode

Platform-dependant string escape
protected _escape_str ( $str ) : string
Résultat string

_get_operator() protected méthode

Returns the SQL string operator
protected _get_operator ( $str ) : string
Résultat string

_has_operator() protected méthode

Tests whether the string has an SQL operator
protected _has_operator ( $str ) : boolean
Résultat boolean

_insert() protected méthode

Generates a platform-specific insert string from the supplied data
protected _insert ( $table, $keys, $values ) : string
Résultat string

_reset_select() protected méthode

Dummy method that allows Query Builder class to be disabled and keep count_all() working.
protected _reset_select ( ) : void
Résultat void

_update() protected méthode

Generates a platform-specific update string from the supplied data
protected _update ( $table, $values ) : string
Résultat string

_version() protected méthode

Version number query string
protected _version ( ) : string
Résultat string

cache_delete() public méthode

Delete the cache files associated with a particular URI
public cache_delete ( string $segment_one = '', string $segment_two = '' ) : boolean
$segment_one string = ''
$segment_two string = ''
Résultat boolean

cache_delete_all() public méthode

Delete All cache files
public cache_delete_all ( ) : boolean
Résultat boolean

cache_off() public méthode

Disable Query Caching
public cache_off ( ) : boolean
Résultat boolean cache_on value

cache_on() public méthode

Enable Query Caching
public cache_on ( ) : boolean
Résultat boolean cache_on value

cache_set_path() public méthode

Set Cache Directory Path
public cache_set_path ( $path = '' ) : void
Résultat void

call_function() public méthode

Enables a native PHP function to be run, using a platform agnostic wrapper.
public call_function ( string $function ) : mixed
$function string Function name
Résultat mixed

close() public méthode

Close DB Connection
public close ( ) : void
Résultat void

compile_binds() public méthode

Compile Bindings
public compile_binds ( $sql, $binds ) : string
Résultat string

count_all() public méthode

Generates a platform-specific query string that counts all records in the specified database
public count_all ( $table = '' ) : integer
Résultat integer

db_connect() public méthode

This is just a dummy method that all drivers will override.
public db_connect ( ) : mixed
Résultat mixed

db_pconnect() public méthode

Persistent database connection
public db_pconnect ( ) : mixed
Résultat mixed

db_select() public méthode

This is just a dummy method to allow drivers without such functionality to not declare it, while others will override it.
public db_select ( ) : boolean
Résultat boolean

db_set_charset() public méthode

Set client character set
public db_set_charset ( $charset ) : boolean
Résultat boolean

display_error() public méthode

Display an error message
public display_error ( $error = '', $swap = '', $native = FALSE ) : string
Résultat string sends the application/views/errors/error_db.php template

elapsed_time() public méthode

Calculate the aggregate query elapsed time
public elapsed_time ( $decimals = 6 ) : string
Résultat string

error() public méthode

Last error
public error ( ) : array
Résultat array

escape() public méthode

Escapes data based on type Sets boolean and null types
public escape ( $str ) : mixed
Résultat mixed

escape_identifiers() public méthode

This function escapes column and table names
public escape_identifiers ( $item ) : mixed
Résultat mixed

escape_like_str() public méthode

Calls the individual driver for platform specific escaping for LIKE conditions
public escape_like_str ( $str ) : mixed
Résultat mixed

escape_str() public méthode

Escape String
public escape_str ( string | string[] $str, boolean $like = FALSE ) : string
$str string | string[] Input string
$like boolean Whether or not the string will be used in a LIKE condition
Résultat string

field_data() public méthode

Returns an object with field data
public field_data ( string $table ) : array
$table string the table name
Résultat array

field_exists() public méthode

Determine if a particular field exists
public field_exists ( $field_name, $table_name ) : boolean
Résultat boolean

initialize() public méthode

Initialize Database Settings
public initialize ( ) : boolean
Résultat boolean

insert_string() public méthode

Generate an insert string
public insert_string ( $table, $data ) : string
Résultat string

is_write_type() public méthode

Determines if a query is a "write" type.
public is_write_type ( $sql ) : boolean
Résultat boolean

last_query() public méthode

Returns the last query that was executed
public last_query ( ) : string
Résultat string

list_fields() public méthode

Fetch Field Names
public list_fields ( string $table ) : array
$table string Table name
Résultat array

list_tables() public méthode

Returns an array of table names
public list_tables ( string $constrain_by_prefix = FALSE ) : array
$constrain_by_prefix string = FALSE
Résultat array

load_rdriver() public méthode

Load the result drivers
public load_rdriver ( ) : string
Résultat string the name of the result class

platform() public méthode

..)
public platform ( ) : string
Résultat string

primary() public méthode

Retrieves the primary key. It assumes that the row in the first position is the primary key
public primary ( string $table ) : string
$table string Table name
Résultat string

protect_identifiers() public méthode

This function is used extensively by the Query Builder class, and by a couple functions in this class. It takes a column or table name (optionally with an alias) and inserts the table prefix onto it. Some logic is necessary in order to deal with column names that include the path. Consider a query like this: SELECT hostname.database.table.column AS c FROM hostname.database.table Or a query with aliasing: SELECT m.member_id, m.member_name FROM members AS m Since the column name can include up to four segments (host, DB, table, column) or also have an alias prefix, we need to do a bit of work to figure this out and insert the table prefix (if it exists) in the proper position, and escape only the correct identifiers.
public protect_identifiers ( $item, $prefix_single = FALSE, $protect_identifiers = NULL, $field_exists = TRUE ) : string
Résultat string

query() public méthode

Accepts an SQL string as input and returns a result object upon successful execution of a "read" type query. Returns boolean TRUE upon successful execution of a "write" type query. Returns boolean FALSE upon failure, and if the $db_debug variable is set to TRUE will raise an error.
public query ( string $sql, array $binds = FALSE, boolean $return_object = NULL ) : mixed
$sql string
$binds array = FALSE An array of binding data
$return_object boolean = NULL
Résultat mixed

reconnect() public méthode

Keep / reestablish the db connection if no queries have been sent for a length of time exceeding the server's idle timeout. This is just a dummy method to allow drivers without such functionality to not declare it, while others will override it.
public reconnect ( ) : void
Résultat void

simple_query() public méthode

Simple Query This is a simplified version of the query() function. Internally we only use it when running transaction commands since they do not require all the features of the main query() function.
public simple_query ( $sql ) : mixed
Résultat mixed

table_exists() public méthode

Determine if a particular table exists
public table_exists ( string $table_name ) : boolean
$table_name string
Résultat boolean

total_queries() public méthode

Returns the total number of queries
public total_queries ( ) : integer
Résultat integer

trans_begin() public méthode

Begin Transaction
public trans_begin ( boolean $test_mode = FALSE ) : boolean
$test_mode boolean
Résultat boolean

trans_commit() public méthode

Commit Transaction
public trans_commit ( ) : boolean
Résultat boolean

trans_complete() public méthode

Complete Transaction
public trans_complete ( ) : boolean
Résultat boolean

trans_off() public méthode

Disable Transactions This permits transactions to be disabled at run-time.
public trans_off ( ) : void
Résultat void

trans_rollback() public méthode

Rollback Transaction
public trans_rollback ( ) : boolean
Résultat boolean

trans_start() public méthode

Start Transaction
public trans_start ( boolean $test_mode = FALSE ) : boolean
$test_mode boolean = FALSE
Résultat boolean

trans_status() public méthode

Lets you retrieve the transaction flag to determine if it has failed
public trans_status ( ) : boolean
Résultat boolean

trans_strict() public méthode

When strict mode is enabled, if you are running multiple groups of transactions, if one group fails all subsequent groups will be rolled back. If strict mode is disabled, each group is treated autonomously, meaning a failure of one group will not affect any others
public trans_strict ( boolean $mode = TRUE ) : void
$mode boolean = TRUE
Résultat void

update_string() public méthode

Generate an update string
public update_string ( $table, $data, $where ) : string
Résultat string

version() public méthode

Returns a string containing the version of the database being used. Most drivers will override this method.
public version ( ) : string
Résultat string

Property Details

$CACHE public_oe property

DB Cache object
See also: CI_DB_cache
public object $CACHE
Résultat object

$_count_string protected_oe property

COUNT string
protected string $_count_string
Résultat string

$_escape_char protected_oe property

Identifier escape character
protected string $_escape_char
Résultat string

$_like_escape_chr protected_oe property

ESCAPE character
protected string $_like_escape_chr
Résultat string

$_like_escape_str protected_oe property

ESCAPE statement string
protected string $_like_escape_str
Résultat string

$_protect_identifiers protected_oe property

Protect identifiers flag
protected bool $_protect_identifiers
Résultat boolean

$_random_keyword protected_oe property

ORDER BY random keyword
protected array $_random_keyword
Résultat array

$_reserved_identifiers protected_oe property

Identifiers that must NOT be escaped.
protected string[] $_reserved_identifiers
Résultat string[]

$_trans_depth protected_oe property

Transaction depth level
protected int $_trans_depth
Résultat integer

$_trans_failure protected_oe property

Used with transactions to determine if a transaction has failed.
protected bool $_trans_failure
Résultat boolean

$_trans_status protected_oe property

Used with transactions to determine if a rollback should occur.
protected bool $_trans_status
Résultat boolean

$benchmark public_oe property

Benchmark time
public int $benchmark
Résultat integer

$bind_marker public_oe property

Character used to identify values in a prepared statement.
public string $bind_marker
Résultat string

$cache_autodel public_oe property

Cache auto-delete flag
public bool $cache_autodel
Résultat boolean

$cache_on public_oe property

Cache On flag
public bool $cache_on
Résultat boolean

$cachedir public_oe property

Cache directory path
public bool $cachedir
Résultat boolean

$char_set public_oe property

Character set
public string $char_set
Résultat string

$conn_id public_oe property

Connection ID
public object|resource $conn_id
Résultat object | resource

$data_cache public_oe property

An internal generic value cache.
public array $data_cache
Résultat array

$database public_oe property

Database name
public string $database
Résultat string

$db_debug public_oe property

Whether to display error messages.
public bool $db_debug
Résultat boolean

$dbcollat public_oe property

Collation
public string $dbcollat
Résultat string

$dbdriver public_oe property

Database driver
public string $dbdriver
Résultat string

$dbprefix public_oe property

Table prefix
public string $dbprefix
Résultat string

$dsn public_oe property

Data Source Name / Connect string
public string $dsn
Résultat string

$encrypt public_oe property

Encryption flag/data
public mixed $encrypt
Résultat mixed

$hostname public_oe property

Hostname
public string $hostname
Résultat string

$password public_oe property

Password
public string $password
Résultat string

$pconnect public_oe property

Persistent connection flag
public bool $pconnect
Résultat boolean

$port public_oe property

Database port
public int $port
Résultat integer

$queries public_oe property

Queries list
See also: CI_DB_driver::$save_queries
public string[] $queries
Résultat string[]

$query_count public_oe property

Executed queries count
public int $query_count
Résultat integer

$query_times public_oe property

A list of times that queries took to execute.
public array $query_times
Résultat array

$result_id public_oe property

Result ID
public object|resource $result_id
Résultat object | resource

$save_queries public_oe property

Whether to keep an in-memory history of queries for debugging purposes.
public bool $save_queries
Résultat boolean

$subdriver public_oe property

Sub-driver
public string $subdriver
Résultat string

$swap_pre public_oe property

Swap Prefix
public string $swap_pre
Résultat string

$trans_enabled public_oe property

Transaction enabled flag
public bool $trans_enabled
Résultat boolean

$trans_strict public_oe property

Strict transaction mode flag
public bool $trans_strict
Résultat boolean

$username public_oe property

Username
public string $username
Résultat string