Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
AdapterInterface Interface Reference
Inheritance diagram for AdapterInterface:
Mysql Adapter Mysql

Public Member Functions

 beginTransaction ()
 
 commit ()
 
 rollBack ()
 
 newTable ($tableName=null, $schemaName=null)
 
 createTable (Table $table)
 
 dropTable ($tableName, $schemaName=null)
 
 createTemporaryTable (Table $table)
 
 createTemporaryTableLike ($temporaryTableName, $originTableName, $ifNotExists=false)
 
 dropTemporaryTable ($tableName, $schemaName=null)
 
 renameTablesBatch (array $tablePairs)
 
 truncateTable ($tableName, $schemaName=null)
 
 isTableExists ($tableName, $schemaName=null)
 
 showTableStatus ($tableName, $schemaName=null)
 
 describeTable ($tableName, $schemaName=null)
 
 createTableByDdl ($tableName, $newTableName)
 
 modifyColumnByDdl ($tableName, $columnName, $definition, $flushData=false, $schemaName=null)
 
 renameTable ($oldTableName, $newTableName, $schemaName=null)
 
 addColumn ($tableName, $columnName, $definition, $schemaName=null)
 
 changeColumn ( $tableName, $oldColumnName, $newColumnName, $definition, $flushData=false, $schemaName=null)
 
 modifyColumn ($tableName, $columnName, $definition, $flushData=false, $schemaName=null)
 
 dropColumn ($tableName, $columnName, $schemaName=null)
 
 tableColumnExists ($tableName, $columnName, $schemaName=null)
 
 addIndex ($tableName, $indexName, $fields, $indexType=self::INDEX_TYPE_INDEX, $schemaName=null)
 
 dropIndex ($tableName, $keyName, $schemaName=null)
 
 getIndexList ($tableName, $schemaName=null)
 
 addForeignKey ( $fkName, $tableName, $columnName, $refTableName, $refColumnName, $onDelete=self::FK_ACTION_CASCADE, $purge=false, $schemaName=null, $refSchemaName=null)
 
 dropForeignKey ($tableName, $fkName, $schemaName=null)
 
 getForeignKeys ($tableName, $schemaName=null)
 
 select ()
 
 insertOnDuplicate ($table, array $data, array $fields=[])
 
 insertMultiple ($table, array $data)
 
 insertArray ($table, array $columns, array $data)
 
 insert ($table, array $bind)
 
 insertForce ($table, array $bind)
 
 update ($table, array $bind, $where='')
 
 delete ($table, $where='')
 
 query ($sql, $bind=[])
 
 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)
 
 quoteInto ($text, $value, $type=null, $count=null)
 
 quoteIdentifier ($ident, $auto=false)
 
 quoteColumnAs ($ident, $alias, $auto=false)
 
 quoteTableAs ($ident, $alias=null, $auto=false)
 
 formatDate ($date, $includeTime=true)
 
 startSetup ()
 
 endSetup ()
 
 setCacheAdapter (\Magento\Framework\Cache\FrontendInterface $cacheAdapter)
 
 allowDdlCache ()
 
 disallowDdlCache ()
 
 resetDdlCache ($tableName=null, $schemaName=null)
 
 saveDdlCache ($tableCacheKey, $ddlType, $data)
 
 loadDdlCache ($tableCacheKey, $ddlType)
 
 prepareSqlCondition ($fieldName, $condition)
 
 prepareColumnValue (array $column, $value)
 
 getCheckSql ($condition, $true, $false)
 
 getIfNullSql ($expression, $value=0)
 
 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 (\Magento\Framework\DB\Select $select, $table, array $fields=[], $mode=false)
 
 selectsByRange ($rangeField, \Magento\Framework\DB\Select $select, $stepCount=100)
 
 updateFromSelect (\Magento\Framework\DB\Select $select, $table)
 
 deleteFromSelect (\Magento\Framework\DB\Select $select, $table)
 
 getTablesChecksum ($tableNames, $schemaName=null)
 
 supportStraightJoin ()
 
 orderRand (\Magento\Framework\DB\Select $select, $field=null)
 
 forUpdate ($sql)
 
 getPrimaryKeyName ($tableName, $schemaName=null)
 
 decodeVarbinary ($value)
 
 getTransactionLevel ()
 
 createTrigger (\Magento\Framework\DB\Ddl\Trigger $trigger)
 
 dropTrigger ($triggerName, $schemaName=null)
 
 getTables ($likeCondition=null)
 
 getCaseSql ($valueName, $casesResults, $defaultValue=null)
 
 getAutoIncrementField ($tableName, $schemaName=null)
 

Data Fields

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.'
 

Detailed Description

Magento Database Adapter Interface

@api

Since
100.0.2

Definition at line 16 of file AdapterInterface.php.

Member Function Documentation

◆ addColumn()

addColumn (   $tableName,
  $columnName,
  $definition,
  $schemaName = null 
)

Adds new column to the 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.

Parameters
string$tableName
string$columnName
array | string$definitionstring specific or universal array DB Server definition
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ addForeignKey()

addForeignKey (   $fkName,
  $tableName,
  $columnName,
  $refTableName,
  $refColumnName,
  $onDelete = self::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

Parameters
string$fkName
string$tableName
string$columnName
string$refTableName
string$refColumnName
string$onDelete
string$onUpdate
boolean$purgetrying remove invalid data
string$schemaName
string$refSchemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

@SuppressWarnings(PHPMD.ExcessiveParameterList)

Implemented in Mysql.

◆ addIndex()

addIndex (   $tableName,
  $indexName,
  $fields,
  $indexType = self::INDEX_TYPE_INDEX,
  $schemaName = null 
)

Add new index to table name

Parameters
string$tableName
string$indexName
string | array$fieldsthe table column name or array of ones
string$indexTypethe index type
string$schemaName
Returns
\Zend_Db_Statement_Interface

Implemented in Mysql.

◆ allowDdlCache()

allowDdlCache ( )

Allow DDL caching

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ beginTransaction()

beginTransaction ( )

Begin new DB transaction for connection

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ changeColumn()

changeColumn (   $tableName,
  $oldColumnName,
  $newColumnName,
  $definition,
  $flushData = false,
  $schemaName = null 
)

Change the column name and definition

For change definition of column - use modifyColumn

Parameters
string$tableName
string$oldColumnName
string$newColumnName
array | string$definition
boolean$flushDataflush table statistic
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ commit()

commit ( )

Commit DB transaction

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ createTable()

createTable ( Table  $table)

Create table from DDL object

Parameters
Table$table
Exceptions

Implemented in Mysql.

◆ createTableByDdl()

createTableByDdl (   $tableName,
  $newTableName 
)

Create \Magento\Framework\DB\Ddl\Table object by data from describe table

Parameters
string$tableName
string$newTableName
Returns
Table

Implemented in Mysql.

◆ createTemporaryTable()

createTemporaryTable ( Table  $table)

Create temporary table from DDL object

Parameters
Table$table
Exceptions

◆ createTemporaryTableLike()

createTemporaryTableLike (   $temporaryTableName,
  $originTableName,
  $ifNotExists = false 
)

Create temporary table from other table

Parameters
string$temporaryTableName
string$originTableName
bool$ifNotExists
Returns
\Zend_Db_Statement_Interface

Implemented in Mysql.

◆ createTrigger()

createTrigger ( \Magento\Framework\DB\Ddl\Trigger  $trigger)

Create trigger

Parameters
\Magento\Framework\DB\Ddl\Trigger$trigger
Returns
\Zend_Db_Statement_Pdo

Implemented in Mysql.

◆ decodeVarbinary()

decodeVarbinary (   $value)

Converts fetched blob into raw binary PHP data. Some DB drivers return blobs as hex-coded strings, so we need to process them.

Parameters
mixed$value
Returns
mixed

Implemented in Mysql.

◆ delete()

delete (   $table,
  $where = '' 
)

Deletes table rows based on a WHERE clause.

Parameters
mixed$tableThe table to update.
mixed$whereDELETE WHERE clause(s).
Returns
int The number of affected rows.

◆ deleteFromSelect()

deleteFromSelect ( \Magento\Framework\DB\Select  $select,
  $table 
)

Get delete from select object query

Parameters
\Magento\Framework\DB\Select$select
string$tablethe table name or alias used in select
Returns
string|int

◆ describeTable()

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

Parameters
string$tableName
string$schemaNameOPTIONAL
Returns
array

Implemented in Mysql.

◆ disableTableKeys()

disableTableKeys (   $tableName,
  $schemaName = null 
)

Stop updating indexes

Parameters
string$tableName
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ disallowDdlCache()

disallowDdlCache ( )

Disallow DDL caching

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ dropColumn()

dropColumn (   $tableName,
  $columnName,
  $schemaName = null 
)

Drop the column from table

Parameters
string$tableName
string$columnName
string$schemaName
Returns
boolean

Implemented in Mysql.

◆ dropForeignKey()

dropForeignKey (   $tableName,
  $fkName,
  $schemaName = null 
)

Drop the Foreign Key from table

Parameters
string$tableName
string$fkName
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ dropIndex()

dropIndex (   $tableName,
  $keyName,
  $schemaName = null 
)

Drop the index from table

Parameters
string$tableName
string$keyName
string$schemaName
Returns
bool|\Zend_Db_Statement_Interface

Implemented in Mysql.

◆ dropTable()

dropTable (   $tableName,
  $schemaName = null 
)

Drop table from database

Parameters
string$tableName
string$schemaName
Returns
boolean

Implemented in Mysql.

◆ dropTemporaryTable()

dropTemporaryTable (   $tableName,
  $schemaName = null 
)

Drop temporary table from database

Parameters
string$tableName
string$schemaName
Returns
boolean

Implemented in Mysql.

◆ dropTrigger()

dropTrigger (   $triggerName,
  $schemaName = null 
)

Drop trigger from database

Parameters
string$triggerName
string | null$schemaName
Returns
bool

Implemented in Mysql.

◆ enableTableKeys()

enableTableKeys (   $tableName,
  $schemaName = null 
)

Re-create missing indexes

Parameters
string$tableName
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ endSetup()

endSetup ( )

Run additional environment after setup

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ fetchAll()

fetchAll (   $sql,
  $bind = [],
  $fetchMode = null 
)

Fetches all SQL result rows as a sequential array. Uses the current fetchMode for the adapter.

Parameters
string | \Magento\Framework\DB\Select$sqlAn SQL SELECT statement.
mixed$bindData to bind into SELECT placeholders.
mixed$fetchModeOverride current fetch mode.
Returns
array

◆ fetchAssoc()

fetchAssoc (   $sql,
  $bind = [] 
)

Fetches all SQL result rows as an associative array.

The first column is the key, the entire row array is the value. You should construct the query to be sure that the first column contains unique values, or else rows with duplicate values in the first column will overwrite previous data.

Parameters
string | \Magento\Framework\DB\Select$sqlAn SQL SELECT statement.
mixed$bindData to bind into SELECT placeholders.
Returns
array

◆ fetchCol()

fetchCol (   $sql,
  $bind = [] 
)

Fetches the first column of all SQL result rows as an array.

The first column in each row is used as the array key.

Parameters
string | \Magento\Framework\DB\Select$sqlAn SQL SELECT statement.
mixed$bindData to bind into SELECT placeholders.
Returns
array

◆ fetchOne()

fetchOne (   $sql,
  $bind = [] 
)

Fetches the first column of the first row of the SQL result.

Parameters
string | \Magento\Framework\DB\Select$sqlAn SQL SELECT statement.
mixed$bindData to bind into SELECT placeholders.
Returns
string

◆ fetchPairs()

fetchPairs (   $sql,
  $bind = [] 
)

Fetches all SQL result rows as an array of key-value pairs.

The first column is the key, the second column is the value.

Parameters
string | \Magento\Framework\DB\Select$sqlAn SQL SELECT statement.
mixed$bindData to bind into SELECT placeholders.
Returns
array

◆ fetchRow()

fetchRow (   $sql,
  $bind = [],
  $fetchMode = null 
)

Fetches the first row of the SQL result. Uses the current fetchMode for the adapter.

Parameters
string | \Magento\Framework\DB\Select$sqlAn SQL SELECT statement.
mixed$bindData to bind into SELECT placeholders.
mixed$fetchModeOverride current fetch mode.
Returns
array

◆ formatDate()

formatDate (   $date,
  $includeTime = true 
)

Format Date to internal database date format

Parameters
int | string | \DateTimeInterface$date
boolean$includeTime
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ forUpdate()

forUpdate (   $sql)

Render SQL FOR UPDATE clause

Parameters
string$sql
Returns
string

Implemented in Mysql.

◆ getAutoIncrementField()

getAutoIncrementField (   $tableName,
  $schemaName = null 
)

Returns auto increment field if exists

Parameters
string$tableName
string | null$schemaName
Returns
string|bool
Since
100.1.0

Implemented in Mysql.

◆ getCaseSql()

getCaseSql (   $valueName,
  $casesResults,
  $defaultValue = null 
)

Generate fragment of SQL, that check value against multiple condition cases and return different result depends on them

Parameters
string$valueNameName of value to check
array$casesResultsCases and results
string$defaultValuevalue to use if value doesn't confirm to any cases
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getCheckSql()

getCheckSql (   $condition,
  $true,
  $false 
)

Generate fragment of SQL, that check condition and return true or false value

Parameters
string$conditionexpression
string$truetrue value
string$falsefalse value
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getConcatSql()

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

Parameters
array$data
string$separatorconcatenate with separator
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getDateAddSql()

getDateAddSql (   $date,
  $interval,
  $unit 
)

Add time values (intervals) to a date value

See also
INTERVAL_* constants for $unit
Parameters
\Zend_Db_Expr | string$datequoted field name or SQL statement
int$interval
string$unit
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getDateExtractSql()

getDateExtractSql (   $date,
  $unit 
)

Extract part of a date

See also
INTERVAL_* constants for $unit
Parameters
\Zend_Db_Expr | string$datequoted field name or SQL statement
string$unit
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getDateFormatSql()

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

Parameters
\Zend_Db_Expr | string$datequoted field name or SQL statement
string$format
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getDatePartSql()

getDatePartSql (   $date)

Extract the date part of a date or datetime expression

Parameters
\Zend_Db_Expr | string$datequoted field name or SQL statement
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getDateSubSql()

getDateSubSql (   $date,
  $interval,
  $unit 
)

Subtract time values (intervals) to a date value

See also
INTERVAL_* constants for $unit
Parameters
\Zend_Db_Expr | string$datequoted field name or SQL statement
int | string$interval
string$unit
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getForeignKeyName()

getForeignKeyName (   $priTableName,
  $priColumnName,
  $refTableName,
  $refColumnName 
)

Retrieve valid foreign key name Check foreign key name length and allowed symbols

Parameters
string$priTableName
string$priColumnName
string$refTableName
string$refColumnName
Returns
string

Implemented in Mysql.

◆ getForeignKeys()

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 ON_UPDATE => string; action type on update row

Parameters
string$tableName
string$schemaName
Returns
array

Implemented in Mysql.

◆ getGreatestSql()

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

Parameters
array$data
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getIfNullSql()

getIfNullSql (   $expression,
  $value = 0 
)

Returns valid IFNULL expression

Parameters
string$expression
string | int$valueOPTIONAL. Applies when $expression is NULL
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getIndexList()

getIndexList (   $tableName,
  $schemaName = null 
)

Returns the 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

Parameters
string$tableName
string$schemaName
Returns
array

Implemented in Mysql.

◆ getIndexName()

getIndexName (   $tableName,
  $fields,
  $indexType = '' 
)

Retrieve valid index name Check index name length and allowed symbols

Parameters
string$tableName
string | array$fieldsthe columns list
string$indexType
Returns
string

Implemented in Mysql.

◆ getLeastSql()

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

Parameters
array$data
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getLengthSql()

getLengthSql (   $string)

Generate fragment of SQL that returns length of character string The string argument must be quoted

Parameters
string$string
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getPrimaryKeyName()

getPrimaryKeyName (   $tableName,
  $schemaName = null 
)

Try to find installed primary key name, if not - formate new one.

Parameters
string$tableNameTable name
string$schemaNameOPTIONAL
Returns
string Primary Key name

Implemented in Mysql.

◆ getStandardDeviationSql()

getStandardDeviationSql (   $expressionField)

Prepare standard deviation sql function

Parameters
\Zend_Db_Expr | string$expressionFieldquoted field name or SQL statement
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getSubstringSql()

getSubstringSql (   $stringExpression,
  $pos,
  $len = null 
)

Prepare substring sql function

Parameters
\Zend_Db_Expr | string$stringExpressionquoted field name or SQL statement
int | string | \Zend_Db_Expr$pos
int | string | \Zend_Db_Expr | null$len
Returns
\Zend_Db_Expr

Implemented in Mysql.

◆ getTableName()

getTableName (   $tableName)

Retrieve valid table name Check table name length and allowed symbols

Parameters
string$tableName
Returns
string

Implemented in Mysql.

◆ getTables()

getTables (   $likeCondition = null)

Retrieve tables list

Parameters
null | string$likeCondition
Returns
array

Implemented in Mysql.

◆ getTablesChecksum()

getTablesChecksum (   $tableNames,
  $schemaName = null 
)

Return array of table(s) checksum as table name - checksum pairs

Parameters
array | string$tableNames
string$schemaName
Returns
array

Implemented in Mysql.

◆ getTransactionLevel()

getTransactionLevel ( )

Get adapter transaction level state. Return 0 if all transactions are complete

Returns
int

Implemented in Mysql.

◆ getTriggerName()

getTriggerName (   $tableName,
  $time,
  $event 
)

Build a trigger name based on table name and trigger details

Parameters
string$tableNameThe table that is the subject of the trigger
string$timeEither "before" or "after"
string$eventThe DB level event which activates the trigger, i.e. "update" or "insert"
Returns
string

Implemented in Mysql.

◆ insert()

insert (   $table,
array  $bind 
)

Inserts a table row with specified data.

Parameters
mixed$tableThe table to insert data into.
array$bindColumn-value pairs.
Returns
int The number of affected rows.

◆ insertArray()

insertArray (   $table,
array  $columns,
array  $data 
)

Insert array into a table based on columns definition

$data can be represented as:

  • arrays of values ordered according to columns in $columns array array( array('value1', 'value2'), array('value3', 'value4'), )
  • array of values, if $columns contains only one column array('value1', 'value2')
Parameters
string$table
string[]$columns the data array column map
array$data
Returns
int

◆ insertForce()

insertForce (   $table,
array  $bind 
)

Inserts a table row with specified data Special for Zero values to identity column

Parameters
string$table
array$bind
Returns
int The number of affected rows.

Implemented in Mysql.

◆ insertFromSelect()

insertFromSelect ( \Magento\Framework\DB\Select  $select,
  $table,
array  $fields = [],
  $mode = false 
)

Get insert from Select object query

Parameters
\Magento\Framework\DB\Select$select
string$tableinsert into table
array$fields
int | bool$mode
Returns
string

◆ insertMultiple()

insertMultiple (   $table,
array  $data 
)

Inserts a table multiply rows with specified data.

Parameters
mixed$tableThe table to insert data into.
array$dataColumn-value pairs or array of Column-value pairs.
Returns
int The number of affected rows.

Implemented in Mysql.

◆ insertOnDuplicate()

insertOnDuplicate (   $table,
array  $data,
array  $fields = [] 
)

Inserts a table row with specified data.

Parameters
mixed$tableThe table to insert data into.
array$dataColumn-value pairs or array of column-value pairs.
array$fieldsupdate fields pairs or values
Returns
int The number of affected rows.

Implemented in Mysql.

◆ isTableExists()

isTableExists (   $tableName,
  $schemaName = null 
)

Checks if table exists

Parameters
string$tableName
string$schemaName
Returns
boolean

Implemented in Mysql.

◆ loadDdlCache()

loadDdlCache (   $tableCacheKey,
  $ddlType 
)

Load DDL data from cache Return false if cache does not exists

Parameters
string$tableCacheKeythe table cache key
int$ddlTypethe DDL constant
Returns
string|array|int|false

Implemented in Mysql.

◆ modifyColumn()

modifyColumn (   $tableName,
  $columnName,
  $definition,
  $flushData = false,
  $schemaName = null 
)

Modify the column definition

Parameters
string$tableName
string$columnName
array | string$definition
boolean$flushData
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ modifyColumnByDdl()

modifyColumnByDdl (   $tableName,
  $columnName,
  $definition,
  $flushData = false,
  $schemaName = null 
)

Modify the column definition by data from describe table

Parameters
string$tableName
string$columnName
array | string$definition
boolean$flushData
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ newTable()

newTable (   $tableName = null,
  $schemaName = null 
)

Retrieve DDL object for new table

Parameters
string$tableNamethe table name
string$schemaNamethe database or schema name
Returns
Table

Implemented in Mysql.

◆ orderRand()

orderRand ( \Magento\Framework\DB\Select  $select,
  $field = null 
)

Adds order by random to select object Possible using integer field for optimization

Parameters
\Magento\Framework\DB\Select$select
string$field
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

◆ prepareColumnValue()

prepareColumnValue ( array  $column,
  $value 
)

Prepare value for save in column Return converted to column data type value

Parameters
array$columnthe column describe array
mixed$value
Returns
mixed

Implemented in Mysql.

◆ prepareSqlCondition()

prepareSqlCondition (   $fieldName,
  $condition 
)

Build SQL statement for condition

If $condition integer or string - exact value will be filtered ('eq' condition)

If $condition is array - one of the following structures is expected:

  • array("from" => $fromValue, "to" => $toValue)
  • array("eq" => $equalValue)
  • array("neq" => $notEqualValue)
  • array("like" => $likeValue)
  • array("in" => array($inValues))
  • array("nin" => array($notInValues))
  • array("notnull" => $valueIsNotNull)
  • array("null" => $valueIsNull)
  • array("moreq" => $moreOrEqualValue)
  • array("gt" => $greaterValue)
  • array("lt" => $lessValue)
  • array("gteq" => $greaterOrEqualValue)
  • array("lteq" => $lessOrEqualValue)
  • array("finset" => $valueInSet)
  • array("regexp" => $regularExpression)
  • array("seq" => $stringValue)
  • array("sneq" => $stringValue)

If non matched - sequential array is expected and OR conditions will be built using above mentioned structure

Parameters
string$fieldName
integer | string | array$condition
Returns
string

Implemented in Mysql.

◆ query()

query (   $sql,
  $bind = [] 
)

Prepares and executes an SQL statement with bound data.

Parameters
mixed$sqlThe SQL statement with placeholders. May be a string or \Magento\Framework\DB\Select.
mixed$bindAn array of data or data itself to bind to the placeholders.
Returns
\Zend_Db_Statement_Interface

Implemented in Mysql.

◆ quote()

quote (   $value,
  $type = null 
)

Safely quotes a value for an SQL statement.

If an array is passed as the value, the array values are quoted and then returned as a comma-separated string.

Parameters
mixed$valueThe value to quote.
mixed$typeOPTIONAL the SQL datatype name, or constant, or null.
Returns
mixed An SQL-safe quoted value (or string of separated values).

◆ quoteColumnAs()

quoteColumnAs (   $ident,
  $alias,
  $auto = false 
)

Quote a column identifier and alias.

Parameters
string | array | \Zend_Db_Expr$identThe identifier or expression.
string$aliasAn alias for the column.
boolean$autoIf true, heed the AUTO_QUOTE_IDENTIFIERS config option.
Returns
string The quoted identifier and alias.

◆ quoteIdentifier()

quoteIdentifier (   $ident,
  $auto = false 
)

Quotes an identifier.

Accepts a string representing a qualified indentifier. For Example: $adapter->quoteIdentifier('myschema.mytable') Returns: "myschema"."mytable"

Or, an array of one or more identifiers that may form a qualified identifier: $adapter->quoteIdentifier(array('myschema','my.table')) Returns: "myschema"."my.table"

The actual quote character surrounding the identifiers may vary depending on the adapter.

Parameters
string | array | \Zend_Db_Expr$identThe identifier.
boolean$autoIf true, heed the AUTO_QUOTE_IDENTIFIERS config option.
Returns
string The quoted identifier.

◆ quoteInto()

quoteInto (   $text,
  $value,
  $type = null,
  $count = null 
)

Quotes a value and places into a piece of text at a placeholder.

The placeholder is a question-mark; all placeholders will be replaced with the quoted value. For example:

$text = "WHERE date < ?"; $date = "2005-01-02"; $safe = $sql->quoteInto($text, $date); // $safe = "WHERE date < '2005-01-02'"

Parameters
string$textThe text with a placeholder.
mixed$valueThe value to quote.
string$typeOPTIONAL SQL datatype
integer$countOPTIONAL count of placeholders to replace
Returns
string An SQL-safe quoted value placed into the original text.

Implemented in Mysql.

◆ quoteTableAs()

quoteTableAs (   $ident,
  $alias = null,
  $auto = false 
)

Quote a table identifier and alias.

Parameters
string | array | \Zend_Db_Expr$identThe identifier or expression.
string$aliasAn alias for the table.
boolean$autoIf true, heed the AUTO_QUOTE_IDENTIFIERS config option.
Returns
string The quoted identifier and alias.

◆ renameTable()

renameTable (   $oldTableName,
  $newTableName,
  $schemaName = null 
)

Rename table

Parameters
string$oldTableName
string$newTableName
string$schemaName
Returns
boolean

Implemented in Mysql.

◆ renameTablesBatch()

renameTablesBatch ( array  $tablePairs)

Rename several tables

Parameters
array$tablePairsarray('oldName' => 'Name1', 'newName' => 'Name2')
Returns
boolean
Exceptions

Implemented in Mysql.

◆ resetDdlCache()

resetDdlCache (   $tableName = null,
  $schemaName = null 
)

Reset cached DDL data from cache if table name is null - reset all cached DDL data

Parameters
string$tableName
string$schemaNameOPTIONAL
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ rollBack()

rollBack ( )

Roll-back DB transaction

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ saveDdlCache()

saveDdlCache (   $tableCacheKey,
  $ddlType,
  $data 
)

Save DDL data into cache

Parameters
string$tableCacheKey
int$ddlType
mixed$data
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ select()

select ( )

Creates and returns a new \Magento\Framework\DB\Select object for this adapter.

Returns
\Magento\Framework\DB\Select

Implemented in Mysql.

◆ selectsByRange()

selectsByRange (   $rangeField,
\Magento\Framework\DB\Select  $select,
  $stepCount = 100 
)

Get insert queries in array for insert by range with step parameter

Parameters
string$rangeField
\Magento\Framework\DB\Select$select
int$stepCount
Returns
\Magento\Framework\DB\Select[]
Exceptions

Implemented in Mysql.

◆ setCacheAdapter()

setCacheAdapter ( \Magento\Framework\Cache\FrontendInterface  $cacheAdapter)

Set cache adapter

Parameters
\Magento\Framework\Cache\FrontendInterface$cacheAdapter
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

◆ showTableStatus()

showTableStatus (   $tableName,
  $schemaName = null 
)

Returns short table status array

Parameters
string$tableName
string$schemaName
Returns
array|false

Implemented in Mysql.

◆ startSetup()

startSetup ( )

Run additional environment before setup

Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ supportStraightJoin()

supportStraightJoin ( )

Check if the database support STRAIGHT JOIN

Returns
boolean

Implemented in Mysql.

◆ tableColumnExists()

tableColumnExists (   $tableName,
  $columnName,
  $schemaName = null 
)

Check is table column exists

Parameters
string$tableName
string$columnName
string$schemaName
Returns
boolean

Implemented in Mysql.

◆ truncateTable()

truncateTable (   $tableName,
  $schemaName = null 
)

Truncate a table

Parameters
string$tableName
string$schemaName
Returns
\Magento\Framework\DB\Adapter\AdapterInterface

Implemented in Mysql.

◆ update()

update (   $table,
array  $bind,
  $where = '' 
)

Updates table rows with specified data based on a WHERE clause.

The $where parameter in this instance can be a single WHERE clause or an array containing a multiple. In all instances, a WHERE clause can be a string or an instance of {

See also
Zend_Db_Expr}. In the event you use an array, you may specify the clause as the key and a value to be bound to it as the value. E.g., ['amt > ?' => $amt]

If the $where parameter is an array of multiple clauses, they will be joined by AND, with each clause wrapped in parenthesis. If you wish to use an OR, you must give a single clause that is an instance of {

See also
Zend_Db_Expr}
Parameters
mixed$tableThe table to update.
array$bindColumn-value pairs.
mixed$whereUPDATE WHERE clause(s).
Returns
int The number of affected rows.

◆ updateFromSelect()

updateFromSelect ( \Magento\Framework\DB\Select  $select,
  $table 
)

Get update table query using select object for join and update

Parameters
\Magento\Framework\DB\Select$select
string | array$table
Returns
string

Field Documentation

◆ ERROR_ASYMMETRIC_COMMIT_MESSAGE

const ERROR_ASYMMETRIC_COMMIT_MESSAGE = 'Asymmetric transaction commit.'

Error message for asymmetric transaction commit

Definition at line 77 of file AdapterInterface.php.

◆ ERROR_ASYMMETRIC_ROLLBACK_MESSAGE

const ERROR_ASYMMETRIC_ROLLBACK_MESSAGE = 'Asymmetric transaction rollback.'

Error message for asymmetric transaction rollback

Definition at line 72 of file AdapterInterface.php.

◆ ERROR_DDL_MESSAGE

const ERROR_DDL_MESSAGE = 'DDL statements are not allowed in transactions'

Error message for DDL query in transactions

Definition at line 62 of file AdapterInterface.php.

◆ ERROR_ROLLBACK_INCOMPLETE_MESSAGE

const ERROR_ROLLBACK_INCOMPLETE_MESSAGE = 'Rolled back transaction has not been completed correctly.'

Error message for unfinished rollBack transaction

Definition at line 67 of file AdapterInterface.php.

◆ FK_ACTION_CASCADE

const FK_ACTION_CASCADE = 'CASCADE'

Definition at line 26 of file AdapterInterface.php.

◆ FK_ACTION_NO_ACTION

const FK_ACTION_NO_ACTION = 'NO ACTION'

Definition at line 30 of file AdapterInterface.php.

◆ FK_ACTION_RESTRICT

const FK_ACTION_RESTRICT = 'RESTRICT'

Definition at line 32 of file AdapterInterface.php.

◆ FK_ACTION_SET_DEFAULT

const FK_ACTION_SET_DEFAULT = 'SET DEFAULT'

Definition at line 34 of file AdapterInterface.php.

◆ FK_ACTION_SET_NULL

const FK_ACTION_SET_NULL = 'SET NULL'

Definition at line 28 of file AdapterInterface.php.

◆ INDEX_TYPE_FULLTEXT

const INDEX_TYPE_FULLTEXT = 'fulltext'

Definition at line 24 of file AdapterInterface.php.

◆ INDEX_TYPE_INDEX

const INDEX_TYPE_INDEX = 'index'

Definition at line 22 of file AdapterInterface.php.

◆ INDEX_TYPE_PRIMARY

const INDEX_TYPE_PRIMARY = 'primary'

Definition at line 18 of file AdapterInterface.php.

◆ INDEX_TYPE_UNIQUE

const INDEX_TYPE_UNIQUE = 'unique'

Definition at line 20 of file AdapterInterface.php.

◆ INSERT_IGNORE

const INSERT_IGNORE = 2

Definition at line 38 of file AdapterInterface.php.

◆ INSERT_ON_DUPLICATE

const INSERT_ON_DUPLICATE = 1

Definition at line 36 of file AdapterInterface.php.

◆ INTERVAL_DAY

const INTERVAL_DAY = 'DAYS'

Definition at line 53 of file AdapterInterface.php.

◆ INTERVAL_HOUR

const INTERVAL_HOUR = 'HOURS'

Definition at line 51 of file AdapterInterface.php.

◆ INTERVAL_MINUTE

const INTERVAL_MINUTE = 'MINUTES'

Definition at line 49 of file AdapterInterface.php.

◆ INTERVAL_MONTH

const INTERVAL_MONTH = 'MONTHS'

Definition at line 55 of file AdapterInterface.php.

◆ INTERVAL_SECOND

const INTERVAL_SECOND = 'SECOND'

Definition at line 47 of file AdapterInterface.php.

◆ INTERVAL_YEAR

const INTERVAL_YEAR = 'YEARS'

Definition at line 57 of file AdapterInterface.php.

◆ ISO_DATE_FORMAT

const ISO_DATE_FORMAT = 'yyyy-MM-dd'

Definition at line 43 of file AdapterInterface.php.

◆ ISO_DATETIME_FORMAT

const ISO_DATETIME_FORMAT = 'yyyy-MM-dd HH-mm-ss'

Definition at line 45 of file AdapterInterface.php.

◆ REPLACE

const REPLACE = 4

Strategy for updating data in table. See https://dev.mysql.com/doc/refman/5.7/en/replace.html

Definition at line 41 of file AdapterInterface.php.


The documentation for this interface was generated from the following file: