Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (StringUtils $string, DateTime $dateTime, LoggerInterface $logger, SelectFactory $selectFactory, array $config=[], SerializerInterface $serializer=null) | |
beginTransaction () | |
commit () | |
rollBack () | |
getTransactionLevel () | |
convertDate ($date) | |
convertDateTime ($datetime) | |
rawQuery ($sql) | |
rawFetchRow ($sql, $field=null) | |
query ($sql, $bind=[]) | |
multiQuery ($sql, $bind=[]) | |
proccessBindCallback ($matches) | |
setQueryHook ($hook) | |
dropForeignKey ($tableName, $fkName, $schemaName=null) | |
purgeOrphanRecords ( $tableName, $columnName, $refTableName, $refColumnName, $onDelete=AdapterInterface::FK_ACTION_CASCADE) | |
tableColumnExists ($tableName, $columnName, $schemaName=null) | |
addColumn ($tableName, $columnName, $definition, $schemaName=null) | |
dropColumn ($tableName, $columnName, $schemaName=null) | |
changeColumn ( $tableName, $oldColumnName, $newColumnName, $definition, $flushData=false, $schemaName=null) | |
modifyColumn ($tableName, $columnName, $definition, $flushData=false, $schemaName=null) | |
showTableStatus ($tableName, $schemaName=null) | |
getCreateTable ($tableName, $schemaName=null) | |
getForeignKeys ($tableName, $schemaName=null) | |
getForeignKeysTree () | |
modifyTables ($tables) | |
getIndexList ($tableName, $schemaName=null) | |
select () | |
quoteInto ($text, $value, $type=null, $count=null) | |
loadDdlCache ($tableCacheKey, $ddlType) | |
saveDdlCache ($tableCacheKey, $ddlType, $data) | |
resetDdlCache ($tableName=null, $schemaName=null) | |
disallowDdlCache () | |
allowDdlCache () | |
describeTable ($tableName, $schemaName=null) | |
getColumnCreateByDescribe ($columnData) | |
createTableByDdl ($tableName, $newTableName) | |
modifyColumnByDdl ($tableName, $columnName, $definition, $flushData=false, $schemaName=null) | |
changeTableEngine ($tableName, $engine, $schemaName=null) | |
changeTableComment ($tableName, $comment, $schemaName=null) | |
insertForce ($table, array $bind) | |
insertOnDuplicate ($table, array $data, array $fields=[]) | |
insertMultiple ($table, array $data) | |
insertArray ($table, array $columns, array $data, $strategy=0) | |
setCacheAdapter (FrontendInterface $cacheAdapter) | |
newTable ($tableName=null, $schemaName=null) | |
createTable (Table $table) | |
createTemporaryTable (\Magento\Framework\DB\Ddl\Table $table) | |
createTemporaryTableLike ($temporaryTableName, $originTableName, $ifNotExists=false) | |
renameTablesBatch (array $tablePairs) | |
getColumnDefinitionFromDescribe ($options, $ddlType=null) | |
dropTable ($tableName, $schemaName=null) | |
dropTemporaryTable ($tableName, $schemaName=null) | |
truncateTable ($tableName, $schemaName=null) | |
isTableExists ($tableName, $schemaName=null) | |
renameTable ($oldTableName, $newTableName, $schemaName=null) | |
addIndex ( $tableName, $indexName, $fields, $indexType=AdapterInterface::INDEX_TYPE_INDEX, $schemaName=null) | |
dropIndex ($tableName, $keyName, $schemaName=null) | |
addForeignKey ( $fkName, $tableName, $columnName, $refTableName, $refColumnName, $onDelete=AdapterInterface::FK_ACTION_CASCADE, $purge=false, $schemaName=null, $refSchemaName=null) | |
formatDate ($date, $includeTime=true) | |
startSetup () | |
endSetup () | |
prepareSqlCondition ($fieldName, $condition) | |
prepareColumnValue (array $column, $value) | |
getCheckSql ($expression, $true, $false) | |
getIfNullSql ($expression, $value=0) | |
getCaseSql ($valueName, $casesResults, $defaultValue=null) | |
getConcatSql (array $data, $separator=null) | |
getLengthSql ($string) | |
getLeastSql (array $data) | |
getGreatestSql (array $data) | |
getDateAddSql ($date, $interval, $unit) | |
getDateSubSql ($date, $interval, $unit) | |
getDateFormatSql ($date, $format) | |
getDatePartSql ($date) | |
getSubstringSql ($stringExpression, $pos, $len=null) | |
getStandardDeviationSql ($expressionField) | |
getDateExtractSql ($date, $unit) | |
getTableName ($tableName) | |
getTriggerName ($tableName, $time, $event) | |
getIndexName ($tableName, $fields, $indexType='') | |
getForeignKeyName ($priTableName, $priColumnName, $refTableName, $refColumnName) | |
disableTableKeys ($tableName, $schemaName=null) | |
enableTableKeys ($tableName, $schemaName=null) | |
insertFromSelect (Select $select, $table, array $fields=[], $mode=false) | |
selectsByRange ($rangeField, \Magento\Framework\DB\Select $select, $stepCount=100) | |
updateFromSelect (Select $select, $table) | |
deleteFromSelect (Select $select, $table) | |
getTablesChecksum ($tableNames, $schemaName=null) | |
supportStraightJoin () | |
orderRand (Select $select, $field=null) | |
forUpdate ($sql) | |
getPrimaryKeyName ($tableName, $schemaName=null) | |
decodeVarbinary ($value) | |
createTrigger (\Magento\Framework\DB\Ddl\Trigger $trigger) | |
dropTrigger ($triggerName, $schemaName=null) | |
__destruct () | |
getTables ($likeCondition=null) | |
getAutoIncrementField ($tableName, $schemaName=null) | |
getSchemaListener () | |
![]() | |
getQuoteIdentifierSymbol () | |
listTables () | |
describeTable ($tableName, $schemaName=null) | |
limit ($sql, $count, $offset=0) | |
![]() | |
isConnected () | |
closeConnection () | |
prepare ($sql) | |
lastInsertId ($tableName=null, $primaryKey=null) | |
query ($sql, $bind=array()) | |
exec ($sql) | |
setFetchMode ($mode) | |
supportsParameters ($type) | |
getServerVersion () | |
![]() | |
__construct ($config) | |
getConnection () | |
getConfig () | |
setProfiler ($profiler) | |
getProfiler () | |
getStatementClass () | |
setStatementClass ($class) | |
query ($sql, $bind=array()) | |
beginTransaction () | |
commit () | |
rollBack () | |
insert ($table, array $bind) | |
update ($table, array $bind, $where='') | |
delete ($table, $where='') | |
select () | |
getFetchMode () | |
fetchAll ($sql, $bind=array(), $fetchMode=null) | |
fetchRow ($sql, $bind=array(), $fetchMode=null) | |
fetchAssoc ($sql, $bind=array()) | |
fetchCol ($sql, $bind=array()) | |
fetchPairs ($sql, $bind=array()) | |
fetchOne ($sql, $bind=array()) | |
quote ($value, $type=null) | |
quoteInto ($text, $value, $type=null, $count=null) | |
quoteIdentifier ($ident, $auto=false) | |
quoteColumnAs ($ident, $alias, $auto=false) | |
quoteTableAs ($ident, $alias=null, $auto=false) | |
getQuoteIdentifierSymbol () | |
lastSequenceId ($sequenceName) | |
nextSequenceId ($sequenceName) | |
foldCase ($key) | |
__sleep () | |
__wakeup () | |
listTables () | |
describeTable ($tableName, $schemaName=null) | |
isConnected () | |
closeConnection () | |
prepare ($sql) | |
lastInsertId ($tableName=null, $primaryKey=null) | |
setFetchMode ($mode) | |
limit ($sql, $count, $offset=0) | |
supportsParameters ($type) | |
getServerVersion () | |
![]() | |
createTemporaryTable (Table $table) | |
insertArray ($table, array $columns, array $data) | |
insert ($table, array $bind) | |
update ($table, array $bind, $where='') | |
delete ($table, $where='') | |
fetchAll ($sql, $bind=[], $fetchMode=null) | |
fetchRow ($sql, $bind=[], $fetchMode=null) | |
fetchAssoc ($sql, $bind=[]) | |
fetchCol ($sql, $bind=[]) | |
fetchPairs ($sql, $bind=[]) | |
fetchOne ($sql, $bind=[]) | |
quote ($value, $type=null) | |
quoteIdentifier ($ident, $auto=false) | |
quoteColumnAs ($ident, $alias, $auto=false) | |
quoteTableAs ($ident, $alias=null, $auto=false) | |
setCacheAdapter (\Magento\Framework\Cache\FrontendInterface $cacheAdapter) | |
insertFromSelect (\Magento\Framework\DB\Select $select, $table, array $fields=[], $mode=false) | |
updateFromSelect (\Magento\Framework\DB\Select $select, $table) | |
deleteFromSelect (\Magento\Framework\DB\Select $select, $table) | |
orderRand (\Magento\Framework\DB\Select $select, $field=null) | |
Data Fields | |
const | TIMESTAMP_FORMAT = 'Y-m-d H:i:s' |
const | DATETIME_FORMAT = 'Y-m-d H:i:s' |
const | DATE_FORMAT = 'Y-m-d' |
const | DDL_DESCRIBE = 1 |
const | DDL_CREATE = 2 |
const | DDL_INDEX = 3 |
const | DDL_FOREIGN_KEY = 4 |
const | DDL_CACHE_PREFIX = 'DB_PDO_MYSQL_DDL' |
const | DDL_CACHE_TAG = 'DB_PDO_MYSQL_DDL' |
const | LENGTH_TABLE_NAME = 64 |
const | LENGTH_INDEX_NAME = 64 |
const | LENGTH_FOREIGN_NAME = 64 |
const | ENGINE_MEMORY = 'MEMORY' |
const | MAX_CONNECTION_RETRIES = 10 |
![]() | |
const | INDEX_TYPE_PRIMARY = 'primary' |
const | INDEX_TYPE_UNIQUE = 'unique' |
const | INDEX_TYPE_INDEX = 'index' |
const | INDEX_TYPE_FULLTEXT = 'fulltext' |
const | FK_ACTION_CASCADE = 'CASCADE' |
const | FK_ACTION_SET_NULL = 'SET NULL' |
const | FK_ACTION_NO_ACTION = 'NO ACTION' |
const | FK_ACTION_RESTRICT = 'RESTRICT' |
const | FK_ACTION_SET_DEFAULT = 'SET DEFAULT' |
const | INSERT_ON_DUPLICATE = 1 |
const | INSERT_IGNORE = 2 |
const | REPLACE = 4 |
const | ISO_DATE_FORMAT = 'yyyy-MM-dd' |
const | ISO_DATETIME_FORMAT = 'yyyy-MM-dd HH-mm-ss' |
const | INTERVAL_SECOND = 'SECOND' |
const | INTERVAL_MINUTE = 'MINUTES' |
const | INTERVAL_HOUR = 'HOURS' |
const | INTERVAL_DAY = 'DAYS' |
const | INTERVAL_MONTH = 'MONTHS' |
const | INTERVAL_YEAR = 'YEARS' |
const | ERROR_DDL_MESSAGE = 'DDL statements are not allowed in transactions' |
const | ERROR_ROLLBACK_INCOMPLETE_MESSAGE = 'Rolled back transaction has not been completed correctly.' |
const | ERROR_ASYMMETRIC_ROLLBACK_MESSAGE = 'Asymmetric transaction rollback.' |
const | ERROR_ASYMMETRIC_COMMIT_MESSAGE = 'Asymmetric transaction commit.' |
Protected Member Functions | |
_connect () | |
_checkDdlTransaction ($sql) | |
_prepareQuery (&$sql, &$bind=[]) | |
_unQuote ($string) | |
_convertMixedBind (&$sql, &$bind) | |
_splitMultiQuery ($sql) | |
_getIndexByColumns ($tableName, array $columns, $schemaName) | |
_removeDuplicateEntry ($table, $fields, $ids) | |
_getTableName ($tableName, $schemaName=null) | |
_getCacheId ($tableKey, $ddlType) | |
_getColumnTypeByDdl ($column) | |
_getColumnsDefinition (Table $table) | |
_getIndexesDefinition (Table $table) | |
isNdb (Table $table) | |
_getForeignKeysDefinition (Table $table) | |
_getOptionsDefinition (Table $table) | |
_getColumnDefinition ($options, $ddlType=null) | |
_prepareQuotedSqlCondition ($text, $value, $fieldName) | |
_transformStringSqlCondition ($conditionKey, $value) | |
_getIntervalUnitSql ($interval, $unit) | |
_prepareInsertData ($row, &$bind) | |
_getInsertSqlQuery ($tableName, array $columns, array $values, $strategy=null) | |
_getReplaceSqlQuery ($tableName, array $columns, array $values) | |
_getDdlType ($options) | |
_getDdlAction ($action) | |
_prepareSqlDateCondition ($condition, $key) | |
_parseTextSize ($size) | |
![]() | |
_dsn () | |
_connect () | |
![]() | |
_dsn () | |
_connect () | |
_quote ($value) | |
_beginTransaction () | |
_commit () | |
_rollBack () | |
![]() | |
_checkRequiredOptions (array $config) | |
_whereExpr ($where) | |
_quote ($value) | |
_quoteIdentifierAs ($ident, $alias=null, $auto=false, $as=' AS ') | |
_quoteIdentifier ($value, $auto=false) | |
_connect () | |
_beginTransaction () | |
_commit () | |
_rollBack () | |
MySQL database adapter
@api @SuppressWarnings(PHPMD.ExcessivePublicCount) @SuppressWarnings(PHPMD.TooManyFields) @SuppressWarnings(PHPMD.ExcessiveClassComplexity) @SuppressWarnings(PHPMD.CouplingBetweenObjects)
__construct | ( | StringUtils | $string, |
DateTime | $dateTime, | ||
LoggerInterface | $logger, | ||
SelectFactory | $selectFactory, | ||
array | $config = [] , |
||
SerializerInterface | $serializer = null |
||
) |
Constructor
StringUtils | $string | |
DateTime | $dateTime | |
LoggerInterface | $logger | |
SelectFactory | $selectFactory | |
array | $config | |
SerializerInterface | null | $serializer |
Definition at line 237 of file Mysql.php.
__destruct | ( | ) |
|
protected |
Check transaction level in case of DDL query
string | \Magento\Framework\DB\Select | $sql |
Definition at line 505 of file Mysql.php.
|
protected |
Creates a PDO object and connects to the database.
@SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)
http://bugs.mysql.com/bug.php?id=18551
Definition at line 374 of file Mysql.php.
|
protected |
|
protected |
|
protected |
Retrieve column definition fragment
array | $options | |
string | $ddlType | Table DDL Column type constant |
Definition at line 2413 of file Mysql.php.
|
protected |
Retrieve columns and primary keys definition array for create table
Table | $table |
Definition at line 2225 of file Mysql.php.
|
protected |
|
protected |
Return DDL action
string | $action |
Definition at line 3794 of file Mysql.php.
|
protected |
|
protected |
Retrieve table foreign keys definition array for create table
Table | $table |
Definition at line 2324 of file Mysql.php.
|
protected |
Retrieve index information by indexed columns or return NULL, if there is no index for a column list
string | $tableName | |
array | $columns | |
string | null | $schemaName |
Definition at line 1058 of file Mysql.php.
|
protected |
Retrieve table indexes definition array for create table
Table | $table |
Definition at line 2263 of file Mysql.php.
|
protected |
Return insert sql query
string | $tableName | |
array | $columns | |
array | $values | |
null | int | $strategy |
Definition at line 3736 of file Mysql.php.
|
protected |
Get Interval Unit SQL fragment
int | $interval | |
string | $unit |
|
protected |
Retrieve table options definition array for create table
Table | $table |
Definition at line 2353 of file Mysql.php.
|
protected |
|
protected |
|
protected |
|
protected |
Prepare insert data
mixed | $row | |
array | $bind |
Definition at line 3710 of file Mysql.php.
|
protected |
Prepares SQL query by moving to bind all special parameters that can be confused with bind placeholders (e.g. "foo:bar"). And also changes named bind to positional one, because underlying library has problems with named binds.
\Magento\Framework\DB\Select | string | $sql | |
mixed | $bind |
|
protected |
Prepare Sql condition
string | $text | Condition value |
mixed | $value | |
string | $fieldName |
Definition at line 2992 of file Mysql.php.
|
protected |
Prepare sql date condition
array | $condition | |
string | $key |
Definition at line 3815 of file Mysql.php.
|
protected |
Remove duplicate entry for create key
string | $table | |
array | $fields | |
string[] | $ids |
Definition at line 1430 of file Mysql.php.
|
protected |
Split multi statement query
string | $sql |
Definition at line 800 of file Mysql.php.
|
protected |
|
protected |
addColumn | ( | $tableName, | |
$columnName, | |||
$definition, | |||
$schemaName = null |
|||
) |
Adds new column to table.
Generally $defintion must be array with column data to keep this call cross-DB compatible. Using string as $definition is allowed only for concrete DB adapter. Adds primary key if needed
string | $tableName | |
string | $columnName | |
array | string | $definition | string specific or universal array DB Server definition |
string | $schemaName |
Implements AdapterInterface.
Definition at line 964 of file Mysql.php.
addForeignKey | ( | $fkName, | |
$tableName, | |||
$columnName, | |||
$refTableName, | |||
$refColumnName, | |||
$onDelete = AdapterInterface::FK_ACTION_CASCADE , |
|||
$purge = false , |
|||
$schemaName = null , |
|||
$refSchemaName = null |
|||
) |
Add new Foreign Key to table If Foreign Key with same name is exist - it will be deleted
string | $fkName | |
string | $tableName | |
string | $columnName | |
string | $refTableName | |
string | $refColumnName | |
string | $onDelete | |
bool | $purge | trying remove invalid data |
string | $schemaName | |
string | $refSchemaName |
Implements AdapterInterface.
Definition at line 2800 of file Mysql.php.
addIndex | ( | $tableName, | |
$indexName, | |||
$fields, | |||
$indexType = AdapterInterface::INDEX_TYPE_INDEX , |
|||
$schemaName = null |
|||
) |
Add new index to table name
string | $tableName | |
string | $indexName | |
string | array | $fields | the table column name or array of ones |
string | $indexType | the index type |
string | $schemaName |
Implements AdapterInterface.
Definition at line 2663 of file Mysql.php.
allowDdlCache | ( | ) |
beginTransaction | ( | ) |
Begin new DB transaction for connection
Implements AdapterInterface.
Definition at line 275 of file Mysql.php.
changeColumn | ( | $tableName, | |
$oldColumnName, | |||
$newColumnName, | |||
$definition, | |||
$flushData = false , |
|||
$schemaName = null |
|||
) |
Change the column name and definition
For change definition of column - use modifyColumn
string | $tableName | |
string | $oldColumnName | |
string | $newColumnName | |
array | $definition | |
boolean | $flushData | flush table statistic |
string | $schemaName |
Implements AdapterInterface.
Definition at line 1082 of file Mysql.php.
changeTableComment | ( | $tableName, | |
$comment, | |||
$schemaName = null |
|||
) |
Change table comment
string | $tableName | |
string | $comment | |
string | $schemaName |
Definition at line 1886 of file Mysql.php.
changeTableEngine | ( | $tableName, | |
$engine, | |||
$schemaName = null |
|||
) |
Change table storage engine
string | $tableName | |
string | $engine | |
string | $schemaName |
Definition at line 1870 of file Mysql.php.
commit | ( | ) |
Commit DB transaction
Implements AdapterInterface.
Definition at line 295 of file Mysql.php.
convertDate | ( | $date | ) |
int | string | \DateTimeInterface | $date |
Definition at line 348 of file Mysql.php.
convertDateTime | ( | $datetime | ) |
Convert date and time to DB format
int | string | \DateTimeInterface | $datetime |
Definition at line 359 of file Mysql.php.
createTable | ( | Table | $table | ) |
Create table
Table | $table |
Implements AdapterInterface.
Definition at line 2105 of file Mysql.php.
createTableByDdl | ( | $tableName, | |
$newTableName | |||
) |
Create \Magento\Framework\DB\Ddl\Table object by data from describe table
string | $tableName | |
string | $newTableName |
Do not create primary index - it is created with identity column. For reliability check both name and type, because these values can start to differ in future.
Implements AdapterInterface.
Definition at line 1735 of file Mysql.php.
createTemporaryTable | ( | \Magento\Framework\DB\Ddl\Table | $table | ) |
Create temporary table
\Magento\Framework\DB\Ddl\Table | $table |
Definition at line 2146 of file Mysql.php.
createTemporaryTableLike | ( | $temporaryTableName, | |
$originTableName, | |||
$ifNotExists = false |
|||
) |
Create temporary table like
string | $temporaryTableName | |
string | $originTableName | |
bool | $ifNotExists |
Implements AdapterInterface.
Definition at line 2173 of file Mysql.php.
createTrigger | ( | \Magento\Framework\DB\Ddl\Trigger | $trigger | ) |
Create trigger
\Magento\Framework\DB\Ddl\Trigger | $trigger |
Implements AdapterInterface.
Definition at line 3900 of file Mysql.php.
decodeVarbinary | ( | $value | ) |
Converts fetched blob into raw binary PHP data. The MySQL drivers do it nice, no processing required.
mixed | $value |
Implements AdapterInterface.
deleteFromSelect | ( | Select | $select, |
$table | |||
) |
describeTable | ( | $tableName, | |
$schemaName = null |
|||
) |
Returns the column descriptions for a table.
The return value is an associative array keyed by the column name, as returned by the RDBMS.
The value of each array element is an associative array with the following keys:
SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; COLUMN_NAME => string; column name COLUMN_POSITION => number; ordinal position of column in table DATA_TYPE => string; SQL datatype name of column DEFAULT => string; default expression of column, null if none NULLABLE => boolean; true if column can have nulls LENGTH => number; length of CHAR/VARCHAR SCALE => number; scale of NUMERIC/DECIMAL PRECISION => number; precision of NUMERIC/DECIMAL UNSIGNED => boolean; unsigned property of an integer type PRIMARY => boolean; true if column is part of the primary key PRIMARY_POSITION => integer; position of column in primary key IDENTITY => integer; true if column is auto-generated with unique values
string | $tableName | |
string | $schemaName | OPTIONAL |
Remove bug in some MySQL versions, when int-column without default value is described as: having default empty string value
Implements AdapterInterface.
Definition at line 1655 of file Mysql.php.
disableTableKeys | ( | $tableName, | |
$schemaName = null |
|||
) |
Stop updating indexes
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 3426 of file Mysql.php.
disallowDdlCache | ( | ) |
dropColumn | ( | $tableName, | |
$columnName, | |||
$schemaName = null |
|||
) |
Delete table column
string | $tableName | |
string | $columnName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 1006 of file Mysql.php.
dropForeignKey | ( | $tableName, | |
$fkName, | |||
$schemaName = null |
|||
) |
Drop the Foreign Key from table
string | $tableName | |
string | $fkName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 863 of file Mysql.php.
dropIndex | ( | $tableName, | |
$keyName, | |||
$schemaName = null |
|||
) |
Drop the index from table
string | $tableName | |
string | $keyName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 2754 of file Mysql.php.
dropTable | ( | $tableName, | |
$schemaName = null |
|||
) |
Drop table from database
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 2553 of file Mysql.php.
dropTemporaryTable | ( | $tableName, | |
$schemaName = null |
|||
) |
Drop temporary table from database
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 2574 of file Mysql.php.
dropTrigger | ( | $triggerName, | |
$schemaName = null |
|||
) |
Drop trigger from database
string | $triggerName | |
string | null | $schemaName |
Implements AdapterInterface.
Definition at line 3933 of file Mysql.php.
enableTableKeys | ( | $tableName, | |
$schemaName = null |
|||
) |
Re-create missing indexes
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 3442 of file Mysql.php.
endSetup | ( | ) |
Run additional environment after setup
Implements AdapterInterface.
Definition at line 2881 of file Mysql.php.
formatDate | ( | $date, | |
$includeTime = true |
|||
) |
Format Date to internal database date format
int | string | \DateTimeInterface | $date | |
bool | $includeTime |
Implements AdapterInterface.
Definition at line 2851 of file Mysql.php.
forUpdate | ( | $sql | ) |
getAutoIncrementField | ( | $tableName, | |
$schemaName = null |
|||
) |
Returns auto increment field if exists
string | $tableName | |
string | null | $schemaName |
Implements AdapterInterface.
Definition at line 3984 of file Mysql.php.
getCaseSql | ( | $valueName, | |
$casesResults, | |||
$defaultValue = null |
|||
) |
Generate fragment of SQL, that check value against multiple condition cases and return different result depends on them
string | $valueName | Name of value to check |
array | $casesResults | Cases and results |
string | $defaultValue | value to use if value doesn't confirm to any cases |
Implements AdapterInterface.
Definition at line 3151 of file Mysql.php.
getCheckSql | ( | $expression, | |
$true, | |||
$false | |||
) |
Generate fragment of SQL, that check condition and return true or false value
\Zend_Db_Expr | \Magento\Framework\DB\Select | string | $expression | |
string | $true | true value |
string | $false | false value |
Implements AdapterInterface.
Definition at line 3113 of file Mysql.php.
getColumnCreateByDescribe | ( | $columnData | ) |
Format described column to definition, ready to be added to ddl table. Return array with keys: name, type, length, options, comment
array | $columnData |
Definition at line 1686 of file Mysql.php.
getColumnDefinitionFromDescribe | ( | $options, | |
$ddlType = null |
|||
) |
Get column definition from description
array | $options | |
null | string | $ddlType |
Definition at line 2391 of file Mysql.php.
getConcatSql | ( | array | $data, |
$separator = null |
|||
) |
Generate fragment of SQL, that combine together (concatenate) the results from data array All arguments in data must be quoted
string[] | $data | |
string | $separator | concatenate with separator |
Implements AdapterInterface.
Definition at line 3173 of file Mysql.php.
getCreateTable | ( | $tableName, | |
$schemaName = null |
|||
) |
Retrieve Create Table SQL
string | $tableName | |
string | $schemaName |
Definition at line 1194 of file Mysql.php.
getDateAddSql | ( | $date, | |
$interval, | |||
$unit | |||
) |
Add time values (intervals) to a date value
\Zend_Db_Expr | string | $date | quoted field name or SQL statement |
int | $interval | |
string | $unit |
Implements AdapterInterface.
Definition at line 3244 of file Mysql.php.
getDateExtractSql | ( | $date, | |
$unit | |||
) |
Extract part of a date
\Zend_Db_Expr | string | $date | quoted field name or SQL statement |
string | $unit |
Implements AdapterInterface.
getDateFormatSql | ( | $date, | |
$format | |||
) |
Format date as specified
Supported format Specifier
H Hour (00..23) i Minutes, numeric (00..59) s Seconds (00..59) d Day of the month, numeric (00..31) m Month, numeric (00..12) Y Year, numeric, four digits
string | $date | quoted date value or non quoted SQL statement(field) |
string | $format |
Implements AdapterInterface.
Definition at line 3282 of file Mysql.php.
getDatePartSql | ( | $date | ) |
Extract the date part of a date or datetime expression
\Zend_Db_Expr | string | $date | quoted field name or SQL statement |
Implements AdapterInterface.
getDateSubSql | ( | $date, | |
$interval, | |||
$unit | |||
) |
Subtract time values (intervals) to a date value
\Zend_Db_Expr | string | $date | quoted field name or SQL statement |
int | string | $interval | |
string | $unit |
Implements AdapterInterface.
Definition at line 3260 of file Mysql.php.
getForeignKeyName | ( | $priTableName, | |
$priColumnName, | |||
$refTableName, | |||
$refColumnName | |||
) |
Retrieve valid foreign key name Check foreign key name length and allowed symbols
string | $priTableName | |
string | $priColumnName | |
string | $refTableName | |
string | $refColumnName |
Implements AdapterInterface.
Definition at line 3413 of file Mysql.php.
getForeignKeys | ( | $tableName, | |
$schemaName = null |
|||
) |
Retrieve the foreign keys descriptions for a table.
The return value is an associative array keyed by the UPPERCASE foreign key, as returned by the RDBMS.
The value of each array element is an associative array with the following keys:
FK_NAME => string; original foreign key name SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; COLUMN_NAME => string; column name REF_SCHEMA_NAME => string; name of reference database or schema REF_TABLE_NAME => string; reference table name REF_COLUMN_NAME => string; reference column name ON_DELETE => string; action type on delete row
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 1229 of file Mysql.php.
getForeignKeysTree | ( | ) |
Retrieve the foreign keys tree for all tables
Definition at line 1268 of file Mysql.php.
getGreatestSql | ( | array | $data | ) |
Generate fragment of SQL, that compare with two or more arguments, and returns the largest (maximum-valued) argument All arguments in data must be quoted
string[] | $data |
Implements AdapterInterface.
Definition at line 3212 of file Mysql.php.
getIfNullSql | ( | $expression, | |
$value = 0 |
|||
) |
Returns valid IFNULL expression
\Zend_Db_Expr | \Magento\Framework\DB\Select | string | $expression | |
string | int | $value | OPTIONAL. Applies when $expression is NULL |
Implements AdapterInterface.
Definition at line 3131 of file Mysql.php.
getIndexList | ( | $tableName, | |
$schemaName = null |
|||
) |
Retrieve table index information
The return value is an associative array keyed by the UPPERCASE index key (except for primary key, that is always stored under 'PRIMARY' key) as returned by the RDBMS.
The value of each array element is an associative array with the following keys:
SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; name of the table KEY_NAME => string; the original index name COLUMNS_LIST => array; array of index column names INDEX_TYPE => string; lowercase, create index type INDEX_METHOD => string; index method using type => string; see INDEX_TYPE fields => array; see COLUMNS_LIST
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 1372 of file Mysql.php.
getIndexName | ( | $tableName, | |
$fields, | |||
$indexType = '' |
|||
) |
Retrieve valid index name Check index name length and allowed symbols
string | $tableName | |
string|string[] | $fields the columns list | |
string | $indexType |
Implements AdapterInterface.
Definition at line 3382 of file Mysql.php.
getLeastSql | ( | array | $data | ) |
Generate fragment of SQL, that compare with two or more arguments, and returns the smallest (minimum-valued) argument All arguments in data must be quoted
string[] | $data |
Implements AdapterInterface.
Definition at line 3199 of file Mysql.php.
getLengthSql | ( | $string | ) |
Generate fragment of SQL that returns length of character string The string argument must be quoted
string | $string |
Implements AdapterInterface.
Definition at line 3186 of file Mysql.php.
getPrimaryKeyName | ( | $tableName, | |
$schemaName = null |
|||
) |
Try to find installed primary key name, if not - formate new one.
string | $tableName | Table name |
string | $schemaName | OPTIONAL |
Implements AdapterInterface.
Definition at line 3837 of file Mysql.php.
getSchemaListener | ( | ) |
Get schema Listener.
Required to listen all DDL changes done by 3-rd party modules with old Install/UpgradeSchema scripts.
Definition at line 4001 of file Mysql.php.
getStandardDeviationSql | ( | $expressionField | ) |
Prepare standard deviation sql function
\Zend_Db_Expr | string | $expressionField | quoted field name or SQL statement |
Implements AdapterInterface.
getSubstringSql | ( | $stringExpression, | |
$pos, | |||
$len = null |
|||
) |
Prepare substring sql function
\Zend_Db_Expr | string | $stringExpression | quoted field name or SQL statement |
int | string | \Zend_Db_Expr | $pos | |
int | string | \Zend_Db_Expr | null | $len |
Implements AdapterInterface.
Definition at line 3307 of file Mysql.php.
getTableName | ( | $tableName | ) |
Returns a compressed version of the table name if it is too long
string | $tableName |
Implements AdapterInterface.
Definition at line 3353 of file Mysql.php.
getTables | ( | $likeCondition = null | ) |
Retrieve tables list
null | string | $likeCondition |
Implements AdapterInterface.
getTablesChecksum | ( | $tableNames, | |
$schemaName = null |
|||
) |
Calculate checksum for table or for group of tables
array | string | $tableNames | array of tables names | table name |
string | $schemaName | schema name |
Implements AdapterInterface.
Definition at line 3646 of file Mysql.php.
getTransactionLevel | ( | ) |
Get adapter transaction level state. Return 0 if all transactions are complete
Implements AdapterInterface.
Definition at line 337 of file Mysql.php.
getTriggerName | ( | $tableName, | |
$time, | |||
$event | |||
) |
Build a trigger name based on table name and trigger details
string | $tableName | The table which is the subject of the trigger |
string | $time | Either "before" or "after" |
string | $event | The DB level event which activates the trigger, i.e. "update" or "insert" |
Implements AdapterInterface.
Definition at line 3367 of file Mysql.php.
insertArray | ( | $table, | |
array | $columns, | ||
array | $data, | ||
$strategy = 0 |
|||
) |
Insert array into a table based on columns definition
$data can be represented as:
string | $table | |
string[] | $columns | |
array | $data | |
int | $strategy |
Definition at line 2036 of file Mysql.php.
insertForce | ( | $table, | |
array | $bind | ||
) |
Inserts a table row with specified data Special for Zero values to identity column
string | $table | |
array | $bind |
Implements AdapterInterface.
Definition at line 1902 of file Mysql.php.
Get insert from Select object query
Select | $select | |
string | $table | insert into table |
array | $fields | |
int | false | $mode |
Definition at line 3460 of file Mysql.php.
insertMultiple | ( | $table, | |
array | $data | ||
) |
Inserts a table multiply rows with specified data.
string | array | \Zend_Db_Expr | $table | The table to insert data into. |
array | $data | Column-value pairs or array of Column-value pairs. |
Implements AdapterInterface.
Definition at line 1991 of file Mysql.php.
insertOnDuplicate | ( | $table, | |
array | $data, | ||
array | $fields = [] |
||
) |
Inserts a table row with specified data.
string | $table | The table to insert data into. |
array | $data | Column-value pairs or array of column-value pairs. |
array | $fields | update fields pairs or values |
Implements AdapterInterface.
Definition at line 1922 of file Mysql.php.
|
protected |
isTableExists | ( | $tableName, | |
$schemaName = null |
|||
) |
Check is a table exists
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 2611 of file Mysql.php.
loadDdlCache | ( | $tableCacheKey, | |
$ddlType | |||
) |
Load DDL data from cache Return false if cache does not exists
string | $tableCacheKey | the table cache key |
int | $ddlType | the DDL constant |
Implements AdapterInterface.
Definition at line 1524 of file Mysql.php.
modifyColumn | ( | $tableName, | |
$columnName, | |||
$definition, | |||
$flushData = false , |
|||
$schemaName = null |
|||
) |
Modify the column definition
string | $tableName | |
string | $columnName | |
array | string | $definition | |
boolean | $flushData | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 1139 of file Mysql.php.
modifyColumnByDdl | ( | $tableName, | |
$columnName, | |||
$definition, | |||
$flushData = false , |
|||
$schemaName = null |
|||
) |
Modify the column definition by data from describe table
string | $tableName | |
string | $columnName | |
array | $definition | |
boolean | $flushData | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 1806 of file Mysql.php.
modifyTables | ( | $tables | ) |
Modify tables, used for upgrade process Change columns definitions, reset foreign keys, change tables comments and engines.
The value of each array element is an associative array with the following keys:
columns => array; list of columns definitions comment => string; table comment engine => string; table engine
array | $tables |
Definition at line 1297 of file Mysql.php.
multiQuery | ( | $sql, | |
$bind = [] |
|||
) |
Allows multiple queries – to safeguard against SQL injection, USE CAUTION and verify that input cannot be tampered with.
Special handling for PDO query(). All bind parameter names must begin with ':'.
string | \Magento\Framework\DB\Select | $sql | The SQL statement with placeholders. |
mixed | $bind | An array of data or data itself to bind to the placeholders. |
newTable | ( | $tableName = null , |
|
$schemaName = null |
|||
) |
Return new DDL Table object
string | $tableName | the table name |
string | $schemaName | the database/schema name |
Implements AdapterInterface.
Definition at line 2082 of file Mysql.php.
orderRand | ( | Select | $select, |
$field = null |
|||
) |
prepareColumnValue | ( | array | $column, |
$value | |||
) |
Prepare value for save in column Return converted to column data type value
array | $column | the column describe array |
mixed | $value |
@SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity)
Implements AdapterInterface.
Definition at line 3029 of file Mysql.php.
prepareSqlCondition | ( | $fieldName, | |
$condition | |||
) |
Build SQL statement for condition
If $condition integer or string - exact value will be filtered ('eq' condition)
If $condition is array is - one of the following structures is expected:
If non matched - sequential array is expected and OR conditions will be built using above mentioned structure
string | $fieldName | |
integer | string | array | $condition |
Implements AdapterInterface.
Definition at line 2920 of file Mysql.php.
proccessBindCallback | ( | $matches | ) |
Callback function for preparation of query and bind by regexp. Checks query parameters for special symbols and moves such parameters to bind array as named ones. This method writes to $_bindParams, where query bind parameters are kept. This method requires further normalizing, if bind array is positional.
string[] | $matches |
Definition at line 687 of file Mysql.php.
purgeOrphanRecords | ( | $tableName, | |
$columnName, | |||
$refTableName, | |||
$refColumnName, | |||
$onDelete = AdapterInterface::FK_ACTION_CASCADE |
|||
) |
Prepare table before add constraint foreign key
string | $tableName | |
string | $columnName | |
string | $refTableName | |
string | $refColumnName | |
string | $onDelete |
Definition at line 895 of file Mysql.php.
query | ( | $sql, | |
$bind = [] |
|||
) |
Special handling for PDO query(). All bind parameter names must begin with ':'.
string | \Magento\Framework\DB\Select | $sql | The SQL statement with placeholders. |
mixed | $bind | An array of data or data itself to bind to the placeholders. |
Implements AdapterInterface.
Definition at line 608 of file Mysql.php.
quoteInto | ( | $text, | |
$value, | |||
$type = null , |
|||
$count = null |
|||
) |
Quotes a value and places into a piece of text at a placeholder.
Method revrited for handle empty arrays in value param
string | $text | The text with a placeholder. |
mixed | $value | The value to quote. |
string | $type | OPTIONAL SQL datatype |
integer | $count | OPTIONAL count of placeholders to replace |
Implements AdapterInterface.
Definition at line 1479 of file Mysql.php.
rawFetchRow | ( | $sql, | |
$field = null |
|||
) |
rawQuery | ( | $sql | ) |
Run RAW Query
string | $sql |
Definition at line 456 of file Mysql.php.
renameTable | ( | $oldTableName, | |
$newTableName, | |||
$schemaName = null |
|||
) |
Rename table
string | $oldTableName | |
string | $newTableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 2625 of file Mysql.php.
renameTablesBatch | ( | array | $tablePairs | ) |
Rename several tables
array | $tablePairs | array('oldName' => 'Name1', 'newName' => 'Name2') |
Implements AdapterInterface.
Definition at line 2191 of file Mysql.php.
resetDdlCache | ( | $tableName = null , |
|
$schemaName = null |
|||
) |
Reset cached DDL data from cache if table name is null - reset all cached DDL data
string | $tableName | |
string | $schemaName | OPTIONAL |
Implements AdapterInterface.
Definition at line 1578 of file Mysql.php.
rollBack | ( | ) |
Rollback DB transaction
Implements AdapterInterface.
Definition at line 316 of file Mysql.php.
saveDdlCache | ( | $tableCacheKey, | |
$ddlType, | |||
$data | |||
) |
Save DDL data into cache
string | $tableCacheKey | |
int | $ddlType | |
array | $data |
Implements AdapterInterface.
Definition at line 1554 of file Mysql.php.
select | ( | ) |
Creates and returns a new \Magento\Framework\DB\Select object for this adapter.
Implements AdapterInterface.
selectsByRange | ( | $rangeField, | |
\Magento\Framework\DB\Select | $select, | ||
$stepCount = 100 |
|||
) |
Get insert queries in array for insert by range with step parameter
string | $rangeField | |
\Magento\Framework\DB\Select | $select | |
int | $stepCount |
LocalizedException |
Implements AdapterInterface.
Definition at line 3517 of file Mysql.php.
setCacheAdapter | ( | FrontendInterface | $cacheAdapter | ) |
setQueryHook | ( | $hook | ) |
showTableStatus | ( | $tableName, | |
$schemaName = null |
|||
) |
Show table status
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 1176 of file Mysql.php.
startSetup | ( | ) |
Run additional environment before setup
Implements AdapterInterface.
Definition at line 2867 of file Mysql.php.
supportStraightJoin | ( | ) |
tableColumnExists | ( | $tableName, | |
$columnName, | |||
$schemaName = null |
|||
) |
Check does table column exist
string | $tableName | |
string | $columnName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 939 of file Mysql.php.
truncateTable | ( | $tableName, | |
$schemaName = null |
|||
) |
Truncate a table
string | $tableName | |
string | $schemaName |
Implements AdapterInterface.
Definition at line 2591 of file Mysql.php.
updateFromSelect | ( | Select | $select, |
$table | |||
) |
Get update table query using select object for join and update
Select | $select | |
string | array | $table |
LocalizedException | @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity) |
Definition at line 3551 of file Mysql.php.
|
protected |
|
protected |
|
protected |
|
protected |
const ENGINE_MEMORY = 'MEMORY' |
const MAX_CONNECTION_RETRIES = 10 |