Class Connection
A connection to a database.
PDO
┗
ICanBoogie\ActiveRecord\Connection
uses
ICanBoogie\Accessor\AccessorTrait (not available)
Methods summary
protected
get_table_name_prefix ( void )
protected
get_charset ( void )
protected
get_collate ( void )
protected
get_timezone ( void )
protected
get_driver_name ( void )
public
__construct ( string $dsn
, string $username
= null , string $password
= null , array $options
= [] )
Establish a connection to a database.
Establish a connection to a database.
Custom options can be specified using the driver-specific connection options. See
ICanBoogie\ActiveRecord\ConnectionOptions
.
Parameters
$dsn
$username
$password
$options
Link
Overrides
PDO::__construct
protected
resolve_driver_name ( string $dsn
)
: string
Resolve the driver name from the DSN string.
Resolve the driver name from the DSN string.
Parameters
Returns
string
protected
apply_options ( array $options
)
Applies options to the instance.
Applies options to the instance.
Parameters
protected
before_connection ( array & $options
)
Called before the connection.
Called before the connection.
May alter the options according to the driver.
Parameters
protected
after_connection ( void )
public
prepare ( string $statement
, array $options
= [] )
: ICanBoogie\ActiveRecord\Statement
Overrides the method to resolve the statement before it is prepared, then set its fetch
mode and connection.
Overrides the method to resolve the statement before it is prepared, then set its fetch
mode and connection.
Parameters
$statement
Query statement.
$options
Returns
Throws
Overrides
PDO::prepare
public
query ( $statement
, array $args
= [] , array $options
= [] )
: ICanBoogie\ActiveRecord\Statement
Overrides the method in order to prepare (and resolve) the statement and execute it with
the specified arguments and options.
Overrides the method in order to prepare (and resolve) the statement and execute it with
the specified arguments and options.
Returns
Inheritdoc
Overrides
PDO::query
public
exec ( $statement
)
public
quote_identifier ( string|array $identifier
)
: string|array
Places quotes around the identifier.
Places quotes around the identifier.
Parameters
Returns
string|array
public
resolve_statement ( string $statement
)
: string
Replaces placeholders with their value.
Replaces placeholders with their value.
The following placeholders are supported:
{prefix}
: replaced by the $table_name_prefix property.
{charset}
: replaced by the $charset property.
{collate}
: replaced by the $collate property.
Parameters
Returns
string The resolved statement.
public
begin ( void )
Alias for the beginTransaction()
method.
Alias for the beginTransaction()
method.
See
PDO::beginTransaction()
public
parse_schema ( array $schema
)
: array
Parses a schema to create a schema with low level definitions.
Parses a schema to create a schema with low level definitions.
For example, a column defined as 'serial' is parsed as :
'type' => 'integer', 'serial' => true, 'size' => 'big', 'unsigned' => true,
'primary' => true
Parameters
Returns
array
public
create_table ( string $unprefixed_name
, array $schema
)
: boolean
Creates a table of the specified name and schema.
Creates a table of the specified name and schema.
Parameters
$unprefixed_name
The unprefixed name of the table.
$schema
The schema of the table.
Returns
boolean
public
table_exists ( string $unprefixed_name
)
: boolean
Checks if a specified table exists in the database.
Checks if a specified table exists in the database.
Parameters
$unprefixed_name
The unprefixed name of the table.
Returns
booleantrue
if the table exists, false
otherwise.
public
optimize ( void )
Optimizes the tables of the database.
Optimizes the tables of the database.
Methods inherited from PDO
__sleep()
,
__wakeup()
,
beginTransaction()
,
commit()
,
errorCode()
,
errorInfo()
,
getAttribute()
,
getAvailableDrivers()
,
inTransaction()
,
lastInsertId()
,
quote()
,
rollBack()
,
setAttribute()
Constants summary
Constants inherited from PDO
ATTR_AUTOCOMMIT
,
ATTR_CASE
,
ATTR_CLIENT_VERSION
,
ATTR_CONNECTION_STATUS
,
ATTR_CURSOR
,
ATTR_CURSOR_NAME
,
ATTR_DEFAULT_FETCH_MODE
,
ATTR_DRIVER_NAME
,
ATTR_EMULATE_PREPARES
,
ATTR_ERRMODE
,
ATTR_FETCH_CATALOG_NAMES
,
ATTR_FETCH_TABLE_NAMES
,
ATTR_MAX_COLUMN_LEN
,
ATTR_ORACLE_NULLS
,
ATTR_PERSISTENT
,
ATTR_PREFETCH
,
ATTR_SERVER_INFO
,
ATTR_SERVER_VERSION
,
ATTR_STATEMENT_CLASS
,
ATTR_STRINGIFY_FETCHES
,
ATTR_TIMEOUT
,
CASE_LOWER
,
CASE_NATURAL
,
CASE_UPPER
,
CURSOR_FWDONLY
,
CURSOR_SCROLL
,
ERRMODE_EXCEPTION
,
ERRMODE_SILENT
,
ERRMODE_WARNING
,
ERR_NONE
,
FETCH_ASSOC
,
FETCH_BOTH
,
FETCH_BOUND
,
FETCH_CLASS
,
FETCH_CLASSTYPE
,
FETCH_COLUMN
,
FETCH_FUNC
,
FETCH_GROUP
,
FETCH_INTO
,
FETCH_KEY_PAIR
,
FETCH_LAZY
,
FETCH_NAMED
,
FETCH_NUM
,
FETCH_OBJ
,
FETCH_ORI_ABS
,
FETCH_ORI_FIRST
,
FETCH_ORI_LAST
,
FETCH_ORI_NEXT
,
FETCH_ORI_PRIOR
,
FETCH_ORI_REL
,
FETCH_PROPS_LATE
,
FETCH_SERIALIZE
,
FETCH_UNIQUE
,
MYSQL_ATTR_COMPRESS
,
MYSQL_ATTR_DIRECT_QUERY
,
MYSQL_ATTR_FOUND_ROWS
,
MYSQL_ATTR_IGNORE_SPACE
,
MYSQL_ATTR_INIT_COMMAND
,
MYSQL_ATTR_LOCAL_INFILE
,
MYSQL_ATTR_MULTI_STATEMENTS
,
MYSQL_ATTR_SERVER_PUBLIC_KEY
,
MYSQL_ATTR_SSL_CA
,
MYSQL_ATTR_SSL_CAPATH
,
MYSQL_ATTR_SSL_CERT
,
MYSQL_ATTR_SSL_CIPHER
,
MYSQL_ATTR_SSL_KEY
,
MYSQL_ATTR_USE_BUFFERED_QUERY
,
NULL_EMPTY_STRING
,
NULL_NATURAL
,
NULL_TO_STRING
,
ODBC_ATTR_ASSUME_UTF8
,
ODBC_ATTR_USE_CURSOR_LIBRARY
,
ODBC_SQL_USE_DRIVER
,
ODBC_SQL_USE_IF_NEEDED
,
ODBC_SQL_USE_ODBC
,
PARAM_BOOL
,
PARAM_EVT_ALLOC
,
PARAM_EVT_EXEC_POST
,
PARAM_EVT_EXEC_PRE
,
PARAM_EVT_FETCH_POST
,
PARAM_EVT_FETCH_PRE
,
PARAM_EVT_FREE
,
PARAM_EVT_NORMALIZE
,
PARAM_INPUT_OUTPUT
,
PARAM_INT
,
PARAM_LOB
,
PARAM_NULL
,
PARAM_STMT
,
PARAM_STR
,
PGSQL_ATTR_DISABLE_PREPARES
,
PGSQL_TRANSACTION_ACTIVE
,
PGSQL_TRANSACTION_IDLE
,
PGSQL_TRANSACTION_INERROR
,
PGSQL_TRANSACTION_INTRANS
,
PGSQL_TRANSACTION_UNKNOWN
Properties summary
public
$queries_count
: integer
The number of database queries and executions, used for statistics purpose.
The number of database queries and executions, used for statistics purpose.
0
public
$profiling
: array[]array
The number of micro seconds spent per request.
The number of micro seconds spent per request.
[]
Magic properties
public read-only
$charset
: string
The character set used to communicate with the database. Defaults to "utf8".
public read-only
$collate
: string
The collation of the character set. Defaults to "utf8_general_ci".
public read-only
$driver_name
: string
public read-only
$id
: string
Identifier of the database connection.
public read-only
$table_name_prefix
: string
The prefix to prepend to every table name.