PHP 클래스 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.
저자: ExpressionEngine Dev Team
파일 보기 프로젝트 열기: tastyigniter/tastyigniter 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$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

보호된 프로퍼티들

프로퍼티 타입 설명
$_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.

공개 메소드들

메소드 설명
__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

보호된 메소드들

메소드 설명
_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

메소드 상세

__construct() 공개 메소드

Class constructor
public __construct ( array $params ) : void
$params array
리턴 void

_cache_init() 보호된 메소드

Initialize the Cache Class
protected _cache_init ( ) : boolean
리턴 boolean

_close() 보호된 메소드

This method would be overridden by most of the drivers.
protected _close ( ) : void
리턴 void

_escape_str() 보호된 메소드

Platform-dependant string escape
protected _escape_str ( $str ) : string
리턴 string

_get_operator() 보호된 메소드

Returns the SQL string operator
protected _get_operator ( $str ) : string
리턴 string

_has_operator() 보호된 메소드

Tests whether the string has an SQL operator
protected _has_operator ( $str ) : boolean
리턴 boolean

_insert() 보호된 메소드

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

_reset_select() 보호된 메소드

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

_update() 보호된 메소드

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

_version() 보호된 메소드

Version number query string
protected _version ( ) : string
리턴 string

cache_delete() 공개 메소드

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 = ''
리턴 boolean

cache_delete_all() 공개 메소드

Delete All cache files
public cache_delete_all ( ) : boolean
리턴 boolean

cache_off() 공개 메소드

Disable Query Caching
public cache_off ( ) : boolean
리턴 boolean cache_on value

cache_on() 공개 메소드

Enable Query Caching
public cache_on ( ) : boolean
리턴 boolean cache_on value

cache_set_path() 공개 메소드

Set Cache Directory Path
public cache_set_path ( $path = '' ) : void
리턴 void

call_function() 공개 메소드

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

close() 공개 메소드

Close DB Connection
public close ( ) : void
리턴 void

compile_binds() 공개 메소드

Compile Bindings
public compile_binds ( $sql, $binds ) : string
리턴 string

count_all() 공개 메소드

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

db_connect() 공개 메소드

This is just a dummy method that all drivers will override.
public db_connect ( ) : mixed
리턴 mixed

db_pconnect() 공개 메소드

Persistent database connection
public db_pconnect ( ) : mixed
리턴 mixed

db_select() 공개 메소드

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
리턴 boolean

db_set_charset() 공개 메소드

Set client character set
public db_set_charset ( $charset ) : boolean
리턴 boolean

display_error() 공개 메소드

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

elapsed_time() 공개 메소드

Calculate the aggregate query elapsed time
public elapsed_time ( $decimals = 6 ) : string
리턴 string

error() 공개 메소드

Last error
public error ( ) : array
리턴 array

escape() 공개 메소드

Escapes data based on type Sets boolean and null types
public escape ( $str ) : mixed
리턴 mixed

escape_identifiers() 공개 메소드

This function escapes column and table names
public escape_identifiers ( $item ) : mixed
리턴 mixed

escape_like_str() 공개 메소드

Calls the individual driver for platform specific escaping for LIKE conditions
public escape_like_str ( $str ) : mixed
리턴 mixed

escape_str() 공개 메소드

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
리턴 string

field_data() 공개 메소드

Returns an object with field data
public field_data ( string $table ) : array
$table string the table name
리턴 array

field_exists() 공개 메소드

Determine if a particular field exists
public field_exists ( $field_name, $table_name ) : boolean
리턴 boolean

initialize() 공개 메소드

Initialize Database Settings
public initialize ( ) : boolean
리턴 boolean

insert_string() 공개 메소드

Generate an insert string
public insert_string ( $table, $data ) : string
리턴 string

is_write_type() 공개 메소드

Determines if a query is a "write" type.
public is_write_type ( $sql ) : boolean
리턴 boolean

last_query() 공개 메소드

Returns the last query that was executed
public last_query ( ) : string
리턴 string

list_fields() 공개 메소드

Fetch Field Names
public list_fields ( string $table ) : array
$table string Table name
리턴 array

list_tables() 공개 메소드

Returns an array of table names
public list_tables ( string $constrain_by_prefix = FALSE ) : array
$constrain_by_prefix string = FALSE
리턴 array

load_rdriver() 공개 메소드

Load the result drivers
public load_rdriver ( ) : string
리턴 string the name of the result class

platform() 공개 메소드

..)
public platform ( ) : string
리턴 string

primary() 공개 메소드

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
리턴 string

protect_identifiers() 공개 메소드

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
리턴 string

query() 공개 메소드

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
리턴 mixed

reconnect() 공개 메소드

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
리턴 void

simple_query() 공개 메소드

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
리턴 mixed

table_exists() 공개 메소드

Determine if a particular table exists
public table_exists ( string $table_name ) : boolean
$table_name string
리턴 boolean

total_queries() 공개 메소드

Returns the total number of queries
public total_queries ( ) : integer
리턴 integer

trans_begin() 공개 메소드

Begin Transaction
public trans_begin ( boolean $test_mode = FALSE ) : boolean
$test_mode boolean
리턴 boolean

trans_commit() 공개 메소드

Commit Transaction
public trans_commit ( ) : boolean
리턴 boolean

trans_complete() 공개 메소드

Complete Transaction
public trans_complete ( ) : boolean
리턴 boolean

trans_off() 공개 메소드

Disable Transactions This permits transactions to be disabled at run-time.
public trans_off ( ) : void
리턴 void

trans_rollback() 공개 메소드

Rollback Transaction
public trans_rollback ( ) : boolean
리턴 boolean

trans_start() 공개 메소드

Start Transaction
public trans_start ( boolean $test_mode = FALSE ) : boolean
$test_mode boolean = FALSE
리턴 boolean

trans_status() 공개 메소드

Lets you retrieve the transaction flag to determine if it has failed
public trans_status ( ) : boolean
리턴 boolean

trans_strict() 공개 메소드

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
리턴 void

update_string() 공개 메소드

Generate an update string
public update_string ( $table, $data, $where ) : string
리턴 string

version() 공개 메소드

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

프로퍼티 상세

$CACHE 공개적으로 프로퍼티

DB Cache object
또한 보기: CI_DB_cache
public object $CACHE
리턴 object

$_count_string 보호되어 있는 프로퍼티

COUNT string
protected string $_count_string
리턴 string

$_escape_char 보호되어 있는 프로퍼티

Identifier escape character
protected string $_escape_char
리턴 string

$_like_escape_chr 보호되어 있는 프로퍼티

ESCAPE character
protected string $_like_escape_chr
리턴 string

$_like_escape_str 보호되어 있는 프로퍼티

ESCAPE statement string
protected string $_like_escape_str
리턴 string

$_protect_identifiers 보호되어 있는 프로퍼티

Protect identifiers flag
protected bool $_protect_identifiers
리턴 boolean

$_random_keyword 보호되어 있는 프로퍼티

ORDER BY random keyword
protected array $_random_keyword
리턴 array

$_reserved_identifiers 보호되어 있는 프로퍼티

Identifiers that must NOT be escaped.
protected string[] $_reserved_identifiers
리턴 string[]

$_trans_depth 보호되어 있는 프로퍼티

Transaction depth level
protected int $_trans_depth
리턴 integer

$_trans_failure 보호되어 있는 프로퍼티

Used with transactions to determine if a transaction has failed.
protected bool $_trans_failure
리턴 boolean

$_trans_status 보호되어 있는 프로퍼티

Used with transactions to determine if a rollback should occur.
protected bool $_trans_status
리턴 boolean

$benchmark 공개적으로 프로퍼티

Benchmark time
public int $benchmark
리턴 integer

$bind_marker 공개적으로 프로퍼티

Character used to identify values in a prepared statement.
public string $bind_marker
리턴 string

$cache_autodel 공개적으로 프로퍼티

Cache auto-delete flag
public bool $cache_autodel
리턴 boolean

$cache_on 공개적으로 프로퍼티

Cache On flag
public bool $cache_on
리턴 boolean

$cachedir 공개적으로 프로퍼티

Cache directory path
public bool $cachedir
리턴 boolean

$char_set 공개적으로 프로퍼티

Character set
public string $char_set
리턴 string

$conn_id 공개적으로 프로퍼티

Connection ID
public object|resource $conn_id
리턴 object | resource

$data_cache 공개적으로 프로퍼티

An internal generic value cache.
public array $data_cache
리턴 array

$database 공개적으로 프로퍼티

Database name
public string $database
리턴 string

$db_debug 공개적으로 프로퍼티

Whether to display error messages.
public bool $db_debug
리턴 boolean

$dbcollat 공개적으로 프로퍼티

Collation
public string $dbcollat
리턴 string

$dbdriver 공개적으로 프로퍼티

Database driver
public string $dbdriver
리턴 string

$dbprefix 공개적으로 프로퍼티

Table prefix
public string $dbprefix
리턴 string

$dsn 공개적으로 프로퍼티

Data Source Name / Connect string
public string $dsn
리턴 string

$encrypt 공개적으로 프로퍼티

Encryption flag/data
public mixed $encrypt
리턴 mixed

$hostname 공개적으로 프로퍼티

Hostname
public string $hostname
리턴 string

$password 공개적으로 프로퍼티

Password
public string $password
리턴 string

$pconnect 공개적으로 프로퍼티

Persistent connection flag
public bool $pconnect
리턴 boolean

$port 공개적으로 프로퍼티

Database port
public int $port
리턴 integer

$queries 공개적으로 프로퍼티

Queries list
또한 보기: CI_DB_driver::$save_queries
public string[] $queries
리턴 string[]

$query_count 공개적으로 프로퍼티

Executed queries count
public int $query_count
리턴 integer

$query_times 공개적으로 프로퍼티

A list of times that queries took to execute.
public array $query_times
리턴 array

$result_id 공개적으로 프로퍼티

Result ID
public object|resource $result_id
리턴 object | resource

$save_queries 공개적으로 프로퍼티

Whether to keep an in-memory history of queries for debugging purposes.
public bool $save_queries
리턴 boolean

$subdriver 공개적으로 프로퍼티

Sub-driver
public string $subdriver
리턴 string

$swap_pre 공개적으로 프로퍼티

Swap Prefix
public string $swap_pre
리턴 string

$trans_enabled 공개적으로 프로퍼티

Transaction enabled flag
public bool $trans_enabled
리턴 boolean

$trans_strict 공개적으로 프로퍼티

Strict transaction mode flag
public bool $trans_strict
리턴 boolean

$username 공개적으로 프로퍼티

Username
public string $username
리턴 string