$connID
$connID : object|resource
Connection ID
Class BaseConnection
getConnection(string|null $alias = null) : mixed
Returns the actual connection object. If both a 'read' and 'write' connection has been specified, you can pass either term in to get that connection. If you pass either alias in and only a single connection is present, it must return the sole connection.
string|null | $alias |
query(string $sql, mixed $binds = null, boolean $setEscapeFlags = true, string $queryClass = 'CodeIgniter\\Database\\Query') : \CodeIgniter\Database\BaseResult|\CodeIgniter\Database\Query|false
Orchestrates a query against the database. Queries must use Database\Statement objects to store the query and build it.
This method works with the cache.
Should automatically handle different connections for read/write queries if needed.
string | $sql | |
mixed | $binds | |
boolean | $setEscapeFlags | |
string | $queryClass |
transStrict(boolean $mode = true) : $this
Enable/disable Transaction Strict Mode
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
boolean | $mode | = true |
prepare(\Closure $func, array $options = array()) : \CodeIgniter\Database\BasePreparedQuery|null
Creates a prepared statement with the database that can then be used to execute multiple statements against. Within the closure, you would build the query in any normal way, though the Query Builder is the expected manner.
Example: $stmt = $db->prepare(function($db) { return $db->table('users') ->where('id', 1) ->get(); })
\Closure | $func | |
array | $options | Passed to the prepare() method |
protectIdentifiers(string|array $item, boolean $prefixSingle = false, boolean $protectIdentifiers = null, boolean $fieldExists = true) : string|array
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.
string|array | $item | |
boolean | $prefixSingle | |
boolean | $protectIdentifiers | |
boolean | $fieldExists |
callFunction(string $functionName, array ...$params) : boolean
This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner.
string | $functionName | |
array | $params variadic |