PHP Class lithium\data\source\database\adapter\MySql

For more information on configuring the database connection, see the __construct() method.
See also: lithium\data\source\database\adapter\MySql::__construct()
Inheritance: extends lithium\data\source\Database
Afficher le fichier Open project: unionofrad/lithium Class Usage Examples

Protected Properties

Свойство Type Description
$_columns array MySQL column type definitions.
$_constraints array Column contraints
$_metas array By default 'escape' is false and 'join' is ' '.
$_quotes array Pair of opening and closing quote characters used for quoting identifiers in queries.

Méthodes publiques

Méthode Description
__construct ( array $config = [] ) : void Constructor. Constructs the MySQL adapter and sets the default port to 3306.
alias ( $alias, $context )
connect ( ) : boolean Connects to the database by constructing DSN string and creating a PDO intance using the parent class. Will set specific options on the connection as provided.
describe ( mixed $entity, array $fields = [], array $meta = [] ) : array Gets the column schema for a given MySQL table.
enabled ( string $feature = null ) : boolean Check for required PHP extension, or supported database feature.
encoding ( $encoding = null ) : mixed Gets or sets the encoding for the connection.
error ( ) : array Retrieves database error message and error code.
sources ( string $model = null ) : array Returns the list of tables in the currently-connected database.
value ( mixed $value, array $schema = [] ) : mixed Converts a given value into the proper type based on a given schema definition.

Méthodes protégées

Méthode Description
_buildColumn ( array $field ) : string Helper for Database::column()
_column ( string $real ) : array Converts database-layer column types to basic types.
_dsn ( ) : string Builds DSN string.
_execute ( string $sql, array $options = [] ) : Result Execute a given query.
_init ( ) Initializer. Adds MySQL-specific operators to $_operators.
_insertId ( object $query ) : mixed Gets the last auto-generated ID from the query that inserted a new record.

Method Details

__construct() public méthode

Constructor. Constructs the MySQL adapter and sets the default port to 3306.
See also: lithium\data\source\Database::__construct()
See also: lithium\data\Source::__construct()
See also: lithium\data\Connections::add()
public __construct ( array $config = [] ) : void
$config array The available configuration options are the following. Further options are inherited from the parent classes. Typically, these parameters are set in `Connections::add()`, when adding the adapter to the list of active connections. - `'host'` _string_: Defaults to `'localhost:3306'`.
Résultat void

_buildColumn() protected méthode

Helper for Database::column()
See also: lithium\data\Database::column()
protected _buildColumn ( array $field ) : string
$field array A field array.
Résultat string The SQL column string.

_column() protected méthode

Converts database-layer column types to basic types.
protected _column ( string $real ) : array
$real string Real database-layer column type (i.e. `"varchar(255)"`)
Résultat array Column type (i.e. "string") plus 'length' when appropriate.

_dsn() protected méthode

Builds DSN string.
protected _dsn ( ) : string
Résultat string

_execute() protected méthode

Execute a given query.
See also: lithium\data\source\Database::renderCommand()
protected _execute ( string $sql, array $options = [] ) : Result
$sql string The sql string to execute
$options array Available options: - 'buffered': If set to `false` uses mysql_unbuffered_query which sends the SQL query query to MySQL without automatically fetching and buffering the result rows as `mysql_query()` does (for less memory usage).
Résultat lithium\data\source\Result Returns a result object if the query was successful.

_init() protected méthode

Initializer. Adds MySQL-specific operators to $_operators.
See also: lithium\data\source\database\adapter\MySql::$_operators
See also: lithium\data\source\Database::$_operators
protected _init ( )

_insertId() protected méthode

Gets the last auto-generated ID from the query that inserted a new record.
protected _insertId ( object $query ) : mixed
$query object The `Query` object associated with the query which generated
Résultat mixed Returns the last inserted ID key for an auto-increment column or a column bound to a sequence.

alias() public méthode

public alias ( $alias, $context )

connect() public méthode

Connects to the database by constructing DSN string and creating a PDO intance using the parent class. Will set specific options on the connection as provided.
public connect ( ) : boolean
Résultat boolean Returns `true` if a database connection could be established, otherwise `false`.

describe() public méthode

Gets the column schema for a given MySQL table.
public describe ( mixed $entity, array $fields = [], array $meta = [] ) : array
$entity mixed Specifies the table name for which the schema should be returned, or the class name of the model object requesting the schema, in which case the model class will be queried for the correct table name.
$fields array Any schema data pre-defined by the model.
$meta array
Résultat array Returns an associative array describing the given table's schema, where the array keys are the available fields, and the values are arrays describing each field, containing the following keys: - `'type'`: The field type name

enabled() public static méthode

Check for required PHP extension, or supported database feature.
public static enabled ( string $feature = null ) : boolean
$feature string Test for support for a specific feature, i.e. `"transactions"` or `"arrays"`.
Résultat boolean Returns `true` if the particular feature (or if MySQL) support is enabled, otherwise `false`.

encoding() public méthode

Gets or sets the encoding for the connection.
public encoding ( $encoding = null ) : mixed
$encoding
Résultat mixed If setting the encoding; returns true on success, else false. When getting, returns the encoding.

error() public méthode

Retrieves database error message and error code.
public error ( ) : array
Résultat array

sources() public méthode

Returns the list of tables in the currently-connected database.
public sources ( string $model = null ) : array
$model string The fully-name-spaced class name of the model object making the request.
Résultat array Returns an array of sources to which models can connect.

value() public méthode

Converts a given value into the proper type based on a given schema definition.
See also: lithium\data\source\Database::schema()
public value ( mixed $value, array $schema = [] ) : mixed
$value mixed The value to be converted. Arrays will be recursively converted.
$schema array Formatted array from `lithium\data\source\Database::schema()`
Résultat mixed Value with converted type.

Property Details

$_columns protected_oe property

MySQL column type definitions.
protected array $_columns
Résultat array

$_constraints protected_oe property

Column contraints
protected array $_constraints
Résultat array

$_metas protected_oe property

By default 'escape' is false and 'join' is ' '.
protected array $_metas
Résultat array

$_quotes protected_oe property

Pair of opening and closing quote characters used for quoting identifiers in queries.
protected array $_quotes
Résultat array