-
Notifications
You must be signed in to change notification settings - Fork 0
Class CI_DB_driver
##Class CI_DB_driver
Database Driver Class
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.
###Direct known subclasses
<a href="Class CI_DB_active_record.md">CI_DB_active_recordggg</a>
Package: [[CodeIgniter<a href="Package CodeIgniter.Drivers.md">Drivers]]
Category:
Database
Author:
ExpressionEngine Dev Team
Link:
http://codeigniter.com/user_guide/database/
Located at system/database/DB_driver.php
##Methods summary
public __construct ( array $params )
Constructor. Accepts one parameter containing the database connection settings.
Parameters
$params
array
public initialize ( )
Initialize Database Settings
public resource db_set_charset ( string $charset, string $collation )
Set client character set
Parameters
$charset
string
$collation
string
Returns
resource
public string platform ( )
The name of the platform in use (mysql, mssql, etc...)
Returns
string
public string version ( )
Database Version Number. Returns a string containing the version of the database being used
Returns
string
public mixed query ( string $sql, array $binds = FALSE, mixed $return_object = TRUE )
Execute the 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.
Parameters
$sql
string
An SQL query string
$binds
array
An array of binding data
$return_object
Returns
mixed
public string load_rdriver ( )
Load the result drivers
Returns
string
the name of the result class
public mixed simple_query ( string $sql )
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.
Parameters
$sql
string
the sql query
Returns
mixed
public trans_off ( )
Disable Transactions This permits transactions to be disabled at run-time.
public trans_strict ( mixed $mode = TRUE )
Enable/disable Transaction Strict Mode When strict mode is enabled, if you are running multiple groups of transactions, if one group fails all 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_start ( mixed $test_mode = FALSE )
Start Transaction
public boolean trans_complete ( )
Complete Transaction
Returns
boolean
public boolean trans_status ( )
Lets you retrieve the transaction flag to determine if it has failed
Returns
boolean
public string compile_binds ( string $sql, array $binds )
Compile Bindings
Parameters
$sql
string
the sql statement
$binds
array
an array of bind data
Returns
string
public boolean is_write_type ( string $sql )
Determines if a query is a "write" type.
Parameters
$sql
string
An SQL query string
Returns
boolean
public integer elapsed_time ( integer $decimals = 6 )
Calculate the aggregate query elapsed time
Parameters
$decimals
integer
The number of decimal places
Returns
integer
public integer total_queries ( )
Returns the total number of queries
Returns
integer
public last_query ( )
Returns the last query that was executed
public mixed escape ( string $str )
"Smart" Escape String
Escapes data based on type Sets boolean and null types
Parameters
$str
string
Returns
mixed
public mixed escape_like_str ( string $str )
Escape LIKE String
Calls the individual driver for platform specific escaping for LIKE conditions
Parameters
$str
string
Returns
mixed
public string primary ( string $table = '' )
Primary
Retrieves the primary key. It assumes that the row in the first position is the primary key
Parameters
$table
string
the table name
Returns
string
public array list_tables ( mixed $constrain_by_prefix = FALSE )
Returns an array of table names
Returns
array
public boolean table_exists ( mixed $table_name )
Determine if a particular table exists
Returns
boolean
public array list_fields ( string $table = '' )
Fetch MySQL Field Names
Parameters
$table
string
the table name
Returns
array
public boolean field_exists ( string $field_name, string $table_name )
Determine if a particular field exists
Parameters
$field_name
string
$table_name
string
Returns
boolean
public object field_data ( string $table = '' )
Returns an object with field data
Parameters
$table
string
the table name
Returns
object
public string insert_string ( string $table, array $data )
Generate an insert string
Parameters
$table
string
the table upon which the query will be performed
$data
array
an associative array data of key/values
Returns
string
public string update_string ( string $table, array $data, mixed $where )
Generate an update string
Parameters
$table
string
the table upon which the query will be performed
$data
array
an associative array data of key/values
$where
mixed
the "where" statement
Returns
string
public boolean _has_operator ( string $str )
Tests whether the string has an SQL operator
Parameters
$str
string
Returns
boolean
public mixed call_function ( string $function )
Enables a native PHP function to be run, using a platform agnostic wrapper.
Parameters
$function
string
the function name
Returns
mixed
public cache_set_path ( string $path = '' )
Set Cache Directory Path
Parameters
$path
string
the path to the cache directory
public cache_on ( )
Enable Query Caching
public cache_off ( )
Disable Query Caching
public cache_delete ( mixed $segment_one = '', mixed $segment_two = '' )
Delete the cache files associated with a particular URI
public cache_delete_all ( )
Delete All cache files
public _cache_init ( )
Initialize the Cache Class
public close ( )
Close DB Connection
public string display_error ( string $error = '', string $swap = '', boolean $native = FALSE )
Display an error message
Parameters
$error
string
the error message
$swap
string
any "swap" values
$native
boolean
whether to localize the message
Returns
string
sends the application/error_db.php template
public mixed protect_identifiers ( mixed $item, mixed $prefix_single = FALSE )
Protect Identifiers
This function adds backticks if appropriate based on db type
Parameters
$item
mixed
the item to escape
$prefix_single
Returns
mixed
the item with backticks
public string _protect_identifiers ( string $item, boolean $prefix_single = FALSE, mixed $protect_identifiers = NULL, boolean $field_exists = TRUE )
Protect Identifiers
This function is used extensively by the Active Record 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 * FROM 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.
Parameters
$item
string
$prefix_single
boolean
$protect_identifiers
mixed
$field_exists
boolean
Returns
string
<table class="summary" id="properties">
<caption>Properties summary</caption>
<tr data-order="username" id="$username">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$username
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="password" id="$password">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$password
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="hostname" id="$hostname">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$hostname
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="database" id="$database">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$database
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="dbdriver" id="$dbdriver">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$dbdriver
'mysql'
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="dbprefix" id="$dbprefix">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$dbprefix
''
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="char_set" id="$char_set">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$char_set
'utf8'
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="dbcollat" id="$dbcollat">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$dbcollat
'utf8_general_ci'
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="autoinit" id="$autoinit">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$autoinit
TRUE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="swap_pre" id="$swap_pre">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$swap_pre
''
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="port" id="$port">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$port
''
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="pconnect" id="$pconnect">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$pconnect
FALSE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="conn_id" id="$conn_id">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$conn_id
FALSE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="result_id" id="$result_id">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$result_id
FALSE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="db_debug" id="$db_debug">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$db_debug
FALSE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="benchmark" id="$benchmark">
<td class="attributes"><code>
public
integer
</code></td>
<td class="name">
$benchmark
0
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="query_count" id="$query_count">
<td class="attributes"><code>
public
integer
</code></td>
<td class="name">
$query_count
0
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="bind_marker" id="$bind_marker">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$bind_marker
'?'
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="save_queries" id="$save_queries">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$save_queries
TRUE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="queries" id="$queries">
<td class="attributes"><code>
public
array
</code></td>
<td class="name">
$queries
array()
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="query_times" id="$query_times">
<td class="attributes"><code>
public
array
</code></td>
<td class="name">
$query_times
array()
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="data_cache" id="$data_cache">
<td class="attributes"><code>
public
array
</code></td>
<td class="name">
$data_cache
array()
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="trans_enabled" id="$trans_enabled">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$trans_enabled
TRUE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="trans_strict" id="$trans_strict">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$trans_strict
TRUE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="_trans_depth" id="$_trans_depth">
<td class="attributes"><code>
public
integer
</code></td>
<td class="name">
$_trans_depth
0
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="_trans_status" id="$_trans_status">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$_trans_status
TRUE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="cache_on" id="$cache_on">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$cache_on
FALSE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="cachedir" id="$cachedir">
<td class="attributes"><code>
public
string
</code></td>
<td class="name">
$cachedir
''
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="cache_autodel" id="$cache_autodel">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$cache_autodel
FALSE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="CACHE" id="$CACHE">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$CACHE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="_protect_identifiers" id="$_protect_identifiers">
<td class="attributes"><code>
public
boolean
</code></td>
<td class="name">
$_protect_identifiers
TRUE
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="_reserved_identifiers" id="$_reserved_identifiers">
<td class="attributes"><code>
public
array
</code></td>
<td class="name">
$_reserved_identifiers
array('*')
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="stmt_id" id="$stmt_id">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$stmt_id
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="curs_id" id="$curs_id">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$curs_id
<div class="description detailed">
</div>
</div></td>
</tr>
<tr data-order="limit_used" id="$limit_used">
<td class="attributes"><code>
public
mixed
</code></td>
<td class="name">
$limit_used
<div class="description detailed">
</div>
</div></td>
</tr>
</table>
API documentation generated by ApiGen 2.8.0
- application
- controlllers
- libraries
- models
- CodeIgniter
- Drivers
- Libraries
- None
- PHP
- Services
- Soundcloud
- About
- API_Controller
- Audioupload_lib
- Auth
- BaseFacebook
- Beats
- Beta
- CI_Benchmark
- CI_Cache
- CI_Cache_apc
- CI_Cache_dummy
- CI_Cache_file
- CI_Cache_memcached
- CI_Calendar
- CI_Cart
- CI_Config
- CI_Controller
- CI_DB_active_record
- CI_DB_Cache
- CI_DB_cubrid_driver
- CI_DB_cubrid_forge
- CI_DB_cubrid_result
- CI_DB_cubrid_utility
- CI_DB_driver
- CI_DB_forge
- CI_DB_mssql_driver
- CI_DB_mssql_forge
- CI_DB_mssql_result
- CI_DB_mssql_utility
- CI_DB_mysql_driver
- CI_DB_mysql_forge
- CI_DB_mysql_result
- CI_DB_mysql_utility
- CI_DB_mysqli_driver
- CI_DB_mysqli_forge
- CI_DB_mysqli_result
- CI_DB_mysqli_utility
- CI_DB_oci8_driver
- CI_DB_oci8_forge
- CI_DB_oci8_result
- CI_DB_oci8_utility
- CI_DB_odbc_driver
- CI_DB_odbc_forge
- CI_DB_odbc_result
- CI_DB_odbc_utility
- CI_DB_pdo_driver
- CI_DB_pdo_forge
- CI_DB_pdo_result
- CI_DB_pdo_utility
- CI_DB_postgre_driver
- CI_DB_postgre_forge
- CI_DB_postgre_result
- CI_DB_postgre_utility
- CI_DB_result
- CI_DB_sqlite_driver
- CI_DB_sqlite_forge
- CI_DB_sqlite_result
- CI_DB_sqlite_utility
- CI_DB_sqlsrv_driver
- CI_DB_sqlsrv_forge
- CI_DB_sqlsrv_result
- CI_DB_sqlsrv_utility
- CI_DB_utility
- CI_Driver
- CI_Driver_Library
- CI_Email
- CI_Encrypt
- CI_Exceptions
- CI_Form_validation
- CI_FTP
- CI_Hooks
- CI_Image_lib
- CI_Input
- CI_Javascript
- CI_Jquery
- CI_Lang
- CI_Loader
- CI_Log
- CI_Migration
- CI_Model
- CI_Output
- CI_Pagination
- CI_Parser
- CI_Profiler
- CI_Router
- CI_Security
- CI_Session
- CI_SHA1
- CI_Table
- CI_Trackback
- CI_Typography
- CI_Unit_test
- CI_Upload
- CI_URI
- CI_User_agent
- CI_Utf8
- CI_Xmlrpc
- CI_Xmlrpcs
- CI_Zip
- Comments_model
- CommercialContent_model
- Components
- Components_model
- Credits_model
- Dashboard
- DevTools
- Download
- Faq
- Featrequest_lib
- Feats
- Feats_model
- FormatterAbstract
- Framework_Controller
- Json_Response
- Local
- Main
- Notification_Formatter
- Notifications_model
- OAUTH_ALGORITHMS
- People
- Points_lib
- Projects
- Search
- SeenContent_model
- Services_Soundcloud
- Services_Soundcloud_Version
- Settings
- Showcases
- Tabs
- Template
- Tools
- UsageNotification
- Users
- Users_lib
- Users_model
- Videos
- vimeo_oauth
- Voices
- XML_RPC_Client
- XML_RPC_Message
- XML_RPC_Response
- XML_RPC_Values
- Exception
- FacebookApiException
- Services_Soundcloud_Invalid_Http_Response_Code_Exception
- Services_Soundcloud_Missing_Client_Id_Exception
- Services_Soundcloud_Unsupported_Audio_Format_Exception
- Services_Soundcloud_Unsupported_Response_Format_Exception
- _attributes_to_string
- _exception_handler
- _get_smiley_array
- _get_validation_object
- _list
- _parse_attributes
- _parse_form_attributes
- alternator
- anchor
- anchor_popup
- ascii_to_entities
- auto_link
- auto_typography
- base64_url_decode
- base_url
- bitly
- br
- build_auth_array
- build_auth_string
- byte_format
- c
- camelize
- canonical_timediff
- character_limiter
- ci_factory
- config_item
- convert_accented_characters
- create_captcha
- curl
- currencyToFloat
- current_url
- days_in_month
- DB
- delete_cookie
- delete_files
- directory_map
- do_hash
- doctype
- element
- elements
- ellipsize
- encode_php_tags
- entities_to_ascii
- entity_decode
- force_download
- form_button
- form_checkbox
- form_close
- form_dropdown
- form_error
- form_fieldset
- form_fieldset_close
- form_hidden
- form_input
- form_label
- form_multiselect
- form_open
- form_open_multipart
- form_password
- form_prep
- form_radio
- form_reset
- form_submit
- form_textarea
- form_upload
- get_auth_header
- get_categories_select
- get_clickable_smileys
- get_config
- get_cookie
- get_country_list
- get_dir_file_info
- get_file_info
- get_filenames
- get_instance
- get_language_select
- get_licences_select
- get_mime_by_extension
- gmt_to_local
- heading
- highlight_code
- highlight_phrase
- html_escape
- human_to_unix
- humanize
- img
- increment_string
- index_page
- is_false
- is_loaded
- is_php
- is_really_writable
- is_true
- js_insert_smiley
- lang
- link_tag
- load_class
- local_to_gmt
- log_message
- mailto
- mdate
- meta
- mysql_to_unix
- nbs
- nl2br_except_pre
- now
- octal_permissions
- ol
- parse_signed_request
- parse_smileys
- parseiOSversions
- plural
- prep_url
- quotes_to_entities
- random_element
- random_string
- read_file
- redirect
- reduce_double_slashes
- reduce_multiples
- remove_invisible_characters
- repeater
- safe_mailto
- sanitize_filename
- sec2min
- send_email
- set_checkbox
- set_cookie
- set_radio
- set_realpath
- set_select
- set_status_header
- set_value
- show_404
- show_comment
- show_error
- sign_hmac_sha1
- sign_rsa_sha1
- since
- singular
- site_url
- smiley_js
- standard_date
- strip_image_tags
- strip_quotes
- strip_slashes
- symbolic_permissions
- timespan
- timezone_menu
- timezones
- trim_slashes
- ul
- underscore
- unix_to_human
- uri_string
- url_title
- user
- user_favorite_list
- user_followed_list
- username
- valid_email
- validation_errors
- word_censor
- word_limiter
- word_wrap
- write_file
- xml_convert
- xss_clean