CodeIgniter v4.6 API

ConnectionInterface

Tags
template
template

Table of Contents

Methods

callFunction()  : array<string|int, mixed>|bool|float|int|object|resource|string|null
Allows for custom calls to the database engine that are not supported through our database layer.
connect()  : false|TConnection
Connect to the database.
error()  : array<string, int|string>
Returns the last error encountered by this connection.
escape()  : mixed
"Smart" Escaping
getConnection()  : false|TConnection
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.
getDatabase()  : string
Returns the name of the current database being used.
getLastQuery()  : Query
Returns the last query's statement object.
getPlatform()  : string
The name of the platform in use (MySQLi, mssql, etc)
getVersion()  : string
Returns a string containing the version of the database being used.
initialize()  : void
Initializes the database connection/settings.
isWriteType()  : bool
Determines if the statement is a write-type query or not.
persistentConnect()  : false|TConnection
Create a persistent database connection.
query()  : BaseResult<TConnection, TResult>|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.
setDatabase()  : bool
Select a specific database table to use.
simpleQuery()  : false|TResult
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.
table()  : BaseBuilder
Returns an instance of the query builder for this connection.

Methods

callFunction()

Allows for custom calls to the database engine that are not supported through our database layer.

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>
Return values
array<string|int, mixed>|bool|float|int|object|resource|string|null

connect()

Connect to the database.

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

error()

Returns the last error encountered by this connection.

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

Must return this format: ['code' => string|int, 'message' => string] intval(code) === 0 means "no error".

Return values
array<string, int|string>

escape()

"Smart" Escaping

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

Escapes data based on type. Sets boolean and null types.

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

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|TConnection
Parameters
$alias : string|null = null
Return values
false|TConnection

getDatabase()

Returns the name of the current database being used.

public getDatabase() : string
Return values
string

getPlatform()

The name of the platform in use (MySQLi, mssql, etc)

public getPlatform() : string
Return values
string

getVersion()

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

public getVersion() : string
Return values
string

initialize()

Initializes the database connection/settings.

public initialize() : void

isWriteType()

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

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

persistentConnect()

Create a persistent database connection.

public persistentConnect() : false|TConnection
Return values
false|TConnection

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 ]) : BaseResult<TConnection, TResult>|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
Return values
BaseResult<TConnection, TResult>|bool|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

setDatabase()

Select a specific database table to use.

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

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|TResult
Parameters
$sql : string
Return values
false|TResult

table()

Returns an instance of the query builder for this connection.

public table(array<string|int, mixed>|string $tableName) : BaseBuilder
Parameters
$tableName : array<string|int, mixed>|string

Table name.

Return values
BaseBuilder

Builder.


        
On this page

Search results