CodeIgniter v4.5 API

Connection extends BaseConnection
in package

Connection for OCI8

Tags
extends

BaseConnection<resource, resource>

Table of Contents

Properties

$aliasedTables  : array<string|int, mixed>
$charset  : string
$commitMode  : int
Commit mode flag
$compress  : bool
$connectDuration  : float
$connectTime  : float
$connID  : false|object|resource
Connection ID
$database  : string
$dataCache  : array<string|int, mixed>
Holds previously looked up data for performance reasons.
$dateFormat  : array<string|int, mixed>
$DBCollat  : string
$DBDebug  : bool
$DBDriver  : string
$DBPrefix  : string
$DSN  : string
$encrypt  : array<string|int, mixed>|bool
$escapeChar  : string
Identifier escape character
$failover  : array<string|int, mixed>
$hostname  : string
$lastInsertedTableName  : string|null
Latest inserted table name.
$lastQuery  : Query
$likeEscapeChar  : string
ESCAPE character
$likeEscapeStr  : string
ESCAPE statement string
$password  : string
$pConnect  : bool
$port  : int|string
$pretend  : bool
$protectIdentifiers  : bool
Protect identifiers flag
$queryClass  : string
$reservedIdentifiers  : array<string|int, mixed>
$resultID  : false|object|resource
Result ID
$strictOn  : bool
$subdriver  : string
$swapPre  : string
$transDepth  : int
$transEnabled  : bool
Transaction enabled flag
$transFailure  : bool
$transStatus  : bool
$transStrict  : bool
Strict transaction mode flag
$username  : string
$aliasedTables  : array<string|int, mixed>
Array of table aliases.
$charset  : string
Character set
$compress  : bool
Compression flag
$connectDuration  : float
How long it took to establish connection.
$connectTime  : float
Microtime when connection was made
$cursorId  : resource
Cursor ID
$database  : string
Database name
$dateFormat  : array<string, string>
Default Date/Time formats
$DBCollat  : string
Collation
$DBDebug  : bool
Whether to throw Exception or not when an error occurs.
$DBDriver  : string
Database driver
$DBPrefix  : string
Table prefix
$DSN  : string
Data Source Name / Connect string
$encrypt  : array<string|int, mixed>|bool
Encryption flag/data
$failover  : array<string|int, mixed>
Settings for a failover connection.
$hostname  : string
Hostname
$lastQuery  : Query
The last query object that was executed on this connection.
$password  : string
Password
$pConnect  : bool
Persistent connection flag
$port  : int|string
Database port
$pregEscapeChar  : array<string|int, mixed>
RegExp used to escape identifiers
$pretend  : bool
If true, no queries will actually be run against the database.
$queryClass  : string
Query Class
$reservedIdentifiers  : array<string|int, mixed>
List of reserved identifiers
$resetStmtId  : mixed
Reset $stmtId flag
$stmtId  : resource
Statement ID
$strictOn  : bool|null
Strict ON flag
$subdriver  : string
Sub-driver
$swapPre  : string
Swap Prefix
$transDepth  : int
Transaction depth level
$transException  : bool
Whether to throw exceptions during transaction
$transFailure  : bool
Transaction failure flag
$transStatus  : bool
Transaction status flag
$username  : string
Username
$validDSNs  : mixed

Methods

__construct()  : mixed
Saves our connection settings.
__get()  : array<string|int, mixed>|bool|float|int|object|resource|string|null
Accessor for properties if they exist.
__isset()  : bool
Checker for properties existence.
addTableAlias()  : $this
Add a table alias to our list.
affectedRows()  : int
Returns the total number of rows affected by this query.
callFunction()  : array<string|int, mixed>|bool|float|int|object|resource|string|null
This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner.
close()  : void
Close the database connection.
connect()  : false|resource
Connect to the database.
disableForeignKeyChecks()  : bool
Disables foreign key checks temporarily.
enableForeignKeyChecks()  : bool
Enables foreign key checks temporarily.
error()  : array<string, int|string|null>
Returns the last error code and message.
escape()  : array<string|int, mixed>|float|int|string
"Smart" Escape String
escapeIdentifier()  : string
Escape the SQL Identifier
escapeIdentifiers()  : array<string|int, mixed>|string
Escape the SQL Identifiers
escapeLikeString()  : array<int, string>|string
Escape LIKE String
escapeString()  : array<int, string>|string
Escape String
fieldExists()  : bool
Determine if a particular field exists
getConnectDuration()  : string
Returns the number of seconds with microseconds that it took to connect to the database.
getConnection()  : false|object|resource
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.
getConnectStart()  : float|null
Returns the time we started to connect to this database in seconds with microseconds.
getCursor()  : resource
Get cursor. Returns a cursor from the database
getDatabase()  : string
Returns the name of the current database being used.
getFieldData()  : array<int, stdClass>
Returns an object with field data
getFieldNames()  : false|array<int, string>
Fetch Field Names
getForeignKeyData()  : array<string, stdClass>
Returns an object with foreign key data
getIndexData()  : array<string, stdClass>
Returns an object with key data
getLastQuery()  : Query
Returns the last query's statement object.
getPlatform()  : string
The name of the platform in use (MySQLi, Postgre, SQLite3, OCI8, etc)
getPrefix()  : string
Returns the database prefix.
getVersion()  : string
Returns a string containing the version of the database being used.
initialize()  : void
Initializes the database connection/settings.
insertID()  : int|string
Insert ID
isWriteType()  : bool
Determines if the statement is a write-type query or not.
listTables()  : false|array<int, string>
Returns an array of table names
newQuery()  : BaseBuilder
Returns a new instance of the BaseBuilder class with a cleared FROM clause.
parseInsertTableName()  : string
Get the table name for the insert statement from sql.
persistentConnect()  : false|object|resource
Create a persistent database connection.
prefixTable()  : string
Prepends a database prefix if one exists in configuration
prepare()  : 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.
pretend()  : $this
Allows the engine to be set into a mode where queries are not actually executed, but they are still generated, timed, etc.
protectIdentifiers()  : array<string|int, mixed>|string
Protect Identifiers
query()  : BaseResult|bool|Query
Orchestrates a query against the database. Queries must use Database\Statement objects to store the query and build it.
reconnect()  : void
Keep or establish the connection if no queries have been sent for a length of time exceeding the server's idle timeout.
resetDataCache()  : $this
Empties our data cache. Especially helpful during testing.
setAliasedTables()  : $this
Sets the Table Aliases to use. These are typically collected during use of the Builder, and set here so queries are built correctly.
setDatabase()  : bool
Select a specific database table to use.
setPrefix()  : string
Set DB Prefix
showLastQuery()  : string
Returns a string representation of the last query's statement object.
simpleQuery()  : false|object|resource
Performs a basic query against the database. No binding or caching is performed, nor are transactions handled. Simply takes a raw query string and returns the database-specific result id.
storedProcedure()  : bool|Query|Result
Executes a stored procedure
table()  : BaseBuilder
Returns a non-shared new instance of the query builder for this connection.
tableExists()  : bool
Determine if a particular table exists
transBegin()  : bool
Begin Transaction
transCommit()  : bool
Commit Transaction
transComplete()  : bool
Complete Transaction
transException()  : $this
If set to true, exceptions are thrown during transactions.
transOff()  : void
Disable Transactions
transRollback()  : bool
Rollback Transaction
transStart()  : bool
Start Transaction
transStatus()  : bool
Lets you retrieve the transaction flag to determine if it has failed
transStrict()  : $this
Enable/disable Transaction Strict Mode
_close()  : void
Close the database connection.
_disableForeignKeyChecks()  : string
Returns platform-specific SQL to disable foreign key checks.
_enableForeignKeyChecks()  : string
Returns platform-specific SQL to enable foreign key checks.
_escapeString()  : string
Platform independent string escape.
_fieldData()  : array<int, stdClass>
Returns an array of objects with field data
_foreignKeyData()  : array<string, stdClass>
Returns an array of objects with Foreign key data
_indexData()  : array<string, stdClass>
Returns an array of objects with index data
_listColumns()  : false|string
Generates a platform-specific query string so that the column names can be fetched.
_listTables()  : false|string
Generates the SQL for listing tables in a platform-dependent manner.
_transBegin()  : bool
Begin Transaction
_transCommit()  : bool
Commit Transaction
_transRollback()  : bool
Rollback Transaction
bindParams()  : void
Bind parameters
buildDSN()  : void
Build a DSN from the provided parameters
execute()  : false|resource
Executes the query against the database.
foreignKeyDataToObjects()  : array<string, stdClass>
Converts array of arrays generated by _foreignKeyData() to array of objects
getDriverFunctionPrefix()  : string
Get the prefix of the function to access the DB.
isValidDSN()  : bool
confirm DSN format.
protectDotItem()  : string

Properties

$aliasedTables read-only

public array<string|int, mixed> $aliasedTables

$commitMode

Commit mode flag

public int $commitMode = OCI_COMMIT_ON_SUCCESS
Tags
used-by

PreparedQuery::_execute()

$connID

Connection ID

public false|object|resource $connID = false
Tags
phpstan-var

false|TConnection

$dataCache

Holds previously looked up data for performance reasons.

public array<string|int, mixed> $dataCache = []

$dateFormat read-only

public array<string|int, mixed> $dateFormat

$escapeChar

Identifier escape character

public string $escapeChar = '"'

$lastInsertedTableName

Latest inserted table name.

public string|null $lastInsertedTableName
Tags
used-by

PreparedQuery::_execute()

$likeEscapeChar

ESCAPE character

public string $likeEscapeChar = '!'

$likeEscapeStr

ESCAPE statement string

public string $likeEscapeStr = " ESCAPE '%s' "

$protectIdentifiers

Protect identifiers flag

public bool $protectIdentifiers = true

$reservedIdentifiers read-only

public array<string|int, mixed> $reservedIdentifiers

$resultID

Result ID

public false|object|resource $resultID = false
Tags
phpstan-var

false|TResult

$transEnabled

Transaction enabled flag

public bool $transEnabled = true

$transStrict

Strict transaction mode flag

public bool $transStrict = true

$aliasedTables

Array of table aliases.

protected array<string|int, mixed> $aliasedTables = []

$charset

Character set

protected string $charset = ''

This value must be updated by Config\Database if the driver use it.

$connectDuration

How long it took to establish connection.

protected float $connectDuration = 0.0

$connectTime

Microtime when connection was made

protected float $connectTime = 0.0

$cursorId

Cursor ID

protected resource $cursorId

$dateFormat

Default Date/Time formats

protected array<string, string> $dateFormat = ['date' => 'Y-m-d', 'datetime' => 'Y-m-d H:i:s', 'datetime-ms' => 'Y-m-d H:i:s.v', 'datetime-us' => 'Y-m-d H:i:s.u', 'time' => 'H:i:s']

$DBCollat

Collation

protected string $DBCollat = ''

This value must be updated by Config\Database if the driver use it.

$DBDebug

Whether to throw Exception or not when an error occurs.

protected bool $DBDebug = true

$DBDriver

Database driver

protected string $DBDriver = 'OCI8'

$encrypt

Encryption flag/data

protected array<string|int, mixed>|bool $encrypt = false

$failover

Settings for a failover connection.

protected array<string|int, mixed> $failover = []

$lastQuery

The last query object that was executed on this connection.

protected Query $lastQuery

$pConnect

Persistent connection flag

protected bool $pConnect = false

$pregEscapeChar

RegExp used to escape identifiers

protected array<string|int, mixed> $pregEscapeChar = []

$pretend

If true, no queries will actually be run against the database.

protected bool $pretend = false

$queryClass

Query Class

protected string $queryClass = \CodeIgniter\Database\Query::class

$reservedIdentifiers

List of reserved identifiers

protected array<string|int, mixed> $reservedIdentifiers = ['*', 'rownum']

Identifiers that must NOT be escaped.

$resetStmtId

Reset $stmtId flag

protected mixed $resetStmtId = true

Used by storedProcedure() to prevent execute() from re-setting the statement ID.

$strictOn

Strict ON flag

Will move to MySQLi\Connection.

protected bool|null $strictOn

Whether we're running in strict SQL mode.

$subdriver

Sub-driver

protected string $subdriver
Tags
used-by

CI_DB_pdo_driver

$transDepth

Transaction depth level

protected int $transDepth = 0

$transException

Whether to throw exceptions during transaction

protected bool $transException = false

$transFailure

Transaction failure flag

protected bool $transFailure = false

Used with transactions to determine if a transaction has failed.

$transStatus

Transaction status flag

protected bool $transStatus = true

Used with transactions to determine if a rollback should occur.

$validDSNs

protected mixed $validDSNs = [ // TNS 'tns' => '/^\(DESCRIPTION=(\(.+\)){2,}\)$/', // Easy Connect string (Oracle 10g+). // https://docs.oracle.com/en/database/oracle/oracle-database/23/netag/configuring-naming-methods.html#GUID-36F3A17D-843C-490A-8A23-FB0FE005F8E8 // [//]host[:port][/[service_name][:server_type][/instance_name]] 'ec' => '/^ (\/\/)? (\[)?[a-z0-9.:_-]+(\])? # Host or IP address (:[1-9][0-9]{0,4})? # Port ( (\/) ([a-z0-9.$_]+)? # Service name (:[a-z]+)? # Server type (\/[a-z0-9$_]+)? # Instance name )? $/ix', // Instance name (defined in tnsnames.ora) 'in' => '/^[a-z0-9$_]+$/i', ]

Methods

__construct()

Saves our connection settings.

public __construct(array<string|int, mixed> $params) : mixed
Parameters
$params : array<string|int, mixed>

__get()

Accessor for properties if they exist.

public __get(string $key) : array<string|int, mixed>|bool|float|int|object|resource|string|null
Parameters
$key : string
Return values
array<string|int, mixed>|bool|float|int|object|resource|string|null

__isset()

Checker for properties existence.

public __isset(string $key) : bool
Parameters
$key : string
Return values
bool

addTableAlias()

Add a table alias to our list.

public addTableAlias(string $table) : $this
Parameters
$table : string
Return values
$this

affectedRows()

Returns the total number of rows affected by this query.

public affectedRows() : int
Return values
int

callFunction()

This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner.

public callFunction(string $functionName, array<string|int, mixed> ...$params) : array<string|int, mixed>|bool|float|int|object|resource|string|null
Parameters
$functionName : string
$params : array<string|int, mixed>
Tags
throws
DatabaseException
Return values
array<string|int, mixed>|bool|float|int|object|resource|string|null

connect()

Connect to the database.

public connect([bool $persistent = false ]) : false|resource
Parameters
$persistent : bool = false
Return values
false|resource

disableForeignKeyChecks()

Disables foreign key checks temporarily.

public disableForeignKeyChecks() : bool
Return values
bool

enableForeignKeyChecks()

Enables foreign key checks temporarily.

public enableForeignKeyChecks() : bool
Return values
bool

error()

Returns the last error code and message.

public error() : array<string, int|string|null>

Must return an array with keys 'code' and 'message':

return ['code' => null, 'message' => null);

Return values
array<string, int|string|null>

escape()

"Smart" Escape String

public escape(array<string|int, mixed>|bool|float|int|object|string|null $str) : array<string|int, mixed>|float|int|string

Escapes data based on type. Sets boolean and null types

Parameters
$str : array<string|int, mixed>|bool|float|int|object|string|null
Tags
phpstan-return

($str is array ? array : float|int|string)

Return values
array<string|int, mixed>|float|int|string

escapeIdentifier()

Escape the SQL Identifier

public escapeIdentifier(non-empty-string $item) : string

This function escapes single identifier.

Parameters
$item : non-empty-string
Return values
string

escapeIdentifiers()

Escape the SQL Identifiers

public escapeIdentifiers(array<string|int, mixed>|string $item) : array<string|int, mixed>|string

This function escapes column and table names

Parameters
$item : array<string|int, mixed>|string
Tags
phpstan-return

($item is array ? array : string)

Return values
array<string|int, mixed>|string

escapeLikeString()

Escape LIKE String

public escapeLikeString(array<int, string|Stringable>|string|Stringable $str) : array<int, string>|string

Calls the individual driver for platform specific escaping for LIKE conditions

Parameters
$str : array<int, string|Stringable>|string|Stringable
Return values
array<int, string>|string

escapeString()

Escape String

public escapeString(array<int, string|Stringable>|string|Stringable $str[, bool $like = false ]) : array<int, string>|string
Parameters
$str : array<int, string|Stringable>|string|Stringable

Input string

$like : bool = false

Whether the string will be used in a LIKE condition

Return values
array<int, string>|string

fieldExists()

Determine if a particular field exists

public fieldExists(string $fieldName, string $tableName) : bool
Parameters
$fieldName : string
$tableName : string
Return values
bool

getConnectDuration()

Returns the number of seconds with microseconds that it took to connect to the database.

public getConnectDuration([int $decimals = 6 ]) : string

Used by the Debug Toolbar's timeline.

Parameters
$decimals : int = 6
Return values
string

getConnection()

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.

public getConnection([string|null $alias = null ]) : false|object|resource
Parameters
$alias : string|null = null
Tags
phpstan-return

TConnection

Return values
false|object|resource

getConnectStart()

Returns the time we started to connect to this database in seconds with microseconds.

public getConnectStart() : float|null

Used by the Debug Toolbar's timeline.

Return values
float|null

getCursor()

Get cursor. Returns a cursor from the database

public getCursor() : resource
Return values
resource

getDatabase()

Returns the name of the current database being used.

public getDatabase() : string
Return values
string

getFieldData()

Returns an object with field data

public getFieldData(string $table) : array<int, stdClass>
Parameters
$table : string
Return values
array<int, stdClass>

getFieldNames()

Fetch Field Names

public getFieldNames(string $table) : false|array<int, string>
Parameters
$table : string
Tags
throws
DatabaseException
Return values
false|array<int, string>

getForeignKeyData()

Returns an object with foreign key data

public getForeignKeyData(string $table) : array<string, stdClass>
Parameters
$table : string
Return values
array<string, stdClass>

getIndexData()

Returns an object with key data

public getIndexData(string $table) : array<string, stdClass>
Parameters
$table : string
Return values
array<string, stdClass>

getPlatform()

The name of the platform in use (MySQLi, Postgre, SQLite3, OCI8, etc)

public getPlatform() : string
Return values
string

getPrefix()

Returns the database prefix.

public getPrefix() : string
Return values
string

getVersion()

Returns a string containing the version of the database being used.

public getVersion() : string
Return values
string

insertID()

Insert ID

public insertID() : int|string
Return values
int|string

isWriteType()

Determines if the statement is a write-type query or not.

public isWriteType(string $sql) : bool
Parameters
$sql : string
Return values
bool

listTables()

Returns an array of table names

public listTables([bool $constrainByPrefix = false ]) : false|array<int, string>
Parameters
$constrainByPrefix : bool = false
Tags
throws
DatabaseException
Return values
false|array<int, string>

parseInsertTableName()

Get the table name for the insert statement from sql.

public parseInsertTableName(string $sql) : string
Parameters
$sql : string
Return values
string

persistentConnect()

Create a persistent database connection.

public persistentConnect() : false|object|resource
Tags
phpstan-return

false|TConnection

Return values
false|object|resource

prefixTable()

Prepends a database prefix if one exists in configuration

public prefixTable([string $table = '' ]) : string
Parameters
$table : string = ''
Tags
throws
DatabaseException
Return values
string

prepare()

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.

public prepare(callable(BaseConnection): mixed $func[, array<string|int, mixed> $options = [] ]) : BasePreparedQuery|null

Example: $stmt = $db->prepare(function($db) { return $db->table('users') ->where('id', 1) ->get(); })

Parameters
$func : callable(BaseConnection): mixed
$options : array<string|int, mixed> = []
Return values
BasePreparedQuery|null

pretend()

Allows the engine to be set into a mode where queries are not actually executed, but they are still generated, timed, etc.

public pretend([bool $pretend = true ]) : $this

This is primarily used by the prepared query functionality.

Parameters
$pretend : bool = true
Return values
$this

protectIdentifiers()

Protect Identifiers

public protectIdentifiers(array<string|int, mixed>|int|string $item[, bool $prefixSingle = false ][, bool $protectIdentifiers = null ][, bool $fieldExists = true ]) : array<string|int, mixed>|string

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.

Parameters
$item : array<string|int, mixed>|int|string
$prefixSingle : bool = false

Prefix a table name with no segments?

$protectIdentifiers : bool = null

Protect table or column names?

$fieldExists : bool = true

Supplied $item contains a column name?

Tags
phpstan-return

($item is array ? array : string)

Return values
array<string|int, mixed>|string

query()

Orchestrates a query against the database. Queries must use Database\Statement objects to store the query and build it.

public query(string $sql[, array<string|int, mixed>|string|null $binds = null ][, bool $setEscapeFlags = true ][, string $queryClass = '' ]) : BaseResult|bool|Query

This method works with the cache.

Should automatically handle different connections for read/write queries if needed.

Parameters
$sql : string
$binds : array<string|int, mixed>|string|null = null
$setEscapeFlags : bool = true
$queryClass : string = ''
Tags
phpstan-return

BaseResult<TConnection, TResult>|bool|Query

todo

BC set $queryClass default as null in 4.1

Return values
BaseResult|bool|Query

BaseResult when “read” type query, bool when “write” type query, Query when prepared query

reconnect()

Keep or establish the connection if no queries have been sent for a length of time exceeding the server's idle timeout.

public reconnect() : void

resetDataCache()

Empties our data cache. Especially helpful during testing.

public resetDataCache() : $this
Return values
$this

setAliasedTables()

Sets the Table Aliases to use. These are typically collected during use of the Builder, and set here so queries are built correctly.

public setAliasedTables(array<string|int, mixed> $aliases) : $this
Parameters
$aliases : array<string|int, mixed>
Return values
$this

setDatabase()

Select a specific database table to use.

public setDatabase(string $databaseName) : bool
Parameters
$databaseName : string
Return values
bool

setPrefix()

Set DB Prefix

public setPrefix([string $prefix = '' ]) : string

Set's the DB Prefix to something new without needing to reconnect

Parameters
$prefix : string = ''

The prefix

Return values
string

showLastQuery()

Returns a string representation of the last query's statement object.

public showLastQuery() : string
Return values
string

simpleQuery()

Performs a basic query against the database. No binding or caching is performed, nor are transactions handled. Simply takes a raw query string and returns the database-specific result id.

public simpleQuery(string $sql) : false|object|resource
Parameters
$sql : string
Tags
phpstan-return

false|TResult

Return values
false|object|resource

storedProcedure()

Executes a stored procedure

public storedProcedure(string $procedureName, array<string|int, mixed> $params) : bool|Query|Result
Parameters
$procedureName : string

procedure name to execute

$params : array<string|int, mixed>

params array keys KEY OPTIONAL NOTES name no the name of the parameter should be in :<param_name> format value no the value of the parameter. If this is an OUT or IN OUT parameter, this should be a reference to a variable type yes the type of the parameter length yes the max size of the parameter

Return values
bool|Query|Result

table()

Returns a non-shared new instance of the query builder for this connection.

public table(array<string|int, mixed>|string $tableName) : BaseBuilder
Parameters
$tableName : array<string|int, mixed>|string
Tags
throws
DatabaseException
Return values
BaseBuilder

tableExists()

Determine if a particular table exists

public tableExists(string $tableName[, bool $cached = true ]) : bool
Parameters
$tableName : string
$cached : bool = true

Whether to use data cache

Return values
bool

transBegin()

Begin Transaction

public transBegin([bool $testMode = false ]) : bool
Parameters
$testMode : bool = false
Return values
bool

transCommit()

Commit Transaction

public transCommit() : bool
Return values
bool

transComplete()

Complete Transaction

public transComplete() : bool
Return values
bool

transException()

If set to true, exceptions are thrown during transactions.

public transException(bool $transException) : $this
Parameters
$transException : bool
Return values
$this

transOff()

Disable Transactions

public transOff() : void

This permits transactions to be disabled at run-time.

transRollback()

Rollback Transaction

public transRollback() : bool
Return values
bool

transStart()

Start Transaction

public transStart([bool $testMode = false ]) : bool
Parameters
$testMode : bool = false
Return values
bool

transStatus()

Lets you retrieve the transaction flag to determine if it has failed

public transStatus() : bool
Return values
bool

transStrict()

Enable/disable Transaction Strict Mode

public transStrict([bool $mode = true ]) : $this

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

Parameters
$mode : bool = true

= true

Return values
$this

_close()

Close the database connection.

protected _close() : void

_disableForeignKeyChecks()

Returns platform-specific SQL to disable foreign key checks.

protected _disableForeignKeyChecks() : string
Return values
string

_enableForeignKeyChecks()

Returns platform-specific SQL to enable foreign key checks.

protected _enableForeignKeyChecks() : string
Return values
string

_escapeString()

Platform independent string escape.

protected _escapeString(string $str) : string

Will likely be overridden in child classes.

Parameters
$str : string
Return values
string

_fieldData()

Returns an array of objects with field data

protected _fieldData(string $table) : array<int, stdClass>
Parameters
$table : string
Tags
throws
DatabaseException
Return values
array<int, stdClass>

_foreignKeyData()

Returns an array of objects with Foreign key data

protected _foreignKeyData(string $table) : array<string, stdClass>
Parameters
$table : string
Tags
throws
DatabaseException
Return values
array<string, stdClass>

_indexData()

Returns an array of objects with index data

protected _indexData(string $table) : array<string, stdClass>
Parameters
$table : string
Tags
throws
DatabaseException
Return values
array<string, stdClass>

_listColumns()

Generates a platform-specific query string so that the column names can be fetched.

protected _listColumns([string $table = '' ]) : false|string
Parameters
$table : string = ''
Return values
false|string

_listTables()

Generates the SQL for listing tables in a platform-dependent manner.

protected _listTables([bool $prefixLimit = false ][, string|null $tableName = null ]) : false|string
Parameters
$prefixLimit : bool = false
$tableName : string|null = null

If $tableName is provided will return only this table if exists.

Return values
false|string

_transBegin()

Begin Transaction

protected _transBegin() : bool
Return values
bool

_transCommit()

Commit Transaction

protected _transCommit() : bool
Return values
bool

_transRollback()

Rollback Transaction

protected _transRollback() : bool
Return values
bool

bindParams()

Bind parameters

protected bindParams(array<string|int, mixed> $params) : void
Parameters
$params : array<string|int, mixed>

buildDSN()

Build a DSN from the provided parameters

protected buildDSN() : void

execute()

Executes the query against the database.

protected execute(string $sql) : false|resource
Parameters
$sql : string
Return values
false|resource

foreignKeyDataToObjects()

Converts array of arrays generated by _foreignKeyData() to array of objects

protected foreignKeyDataToObjects(array<string|int, mixed> $data) : array<string, stdClass>
Parameters
$data : array<string|int, mixed>
Return values
array<string, stdClass>

array[ {constraint_name} => stdClass[ 'constraint_name' => string, 'table_name' => string, 'column_name' => string[], 'foreign_table_name' => string, 'foreign_column_name' => string[], 'on_delete' => string, 'on_update' => string, 'match' => string ] ]

getDriverFunctionPrefix()

Get the prefix of the function to access the DB.

protected getDriverFunctionPrefix() : string
Return values
string

isValidDSN()

confirm DSN format.

private isValidDSN() : bool
Return values
bool

protectDotItem()

private protectDotItem(string $item, string $alias, bool $protectIdentifiers, bool $fieldExists) : string
Parameters
$item : string
$alias : string
$protectIdentifiers : bool
$fieldExists : bool
Return values
string

        
On this page

Search results