This file contains the upgrade notes. These notes highlight changes that could break your application when you upgrade the package from one version to another.
Important! The following upgrading instructions are cumulative. That is, if you want to upgrade from version A to version C and there is version B between A and C, you need to following the instructions for both A and B.
- Remove
ColumnInterfaceand useColumnSchemaInterfaceinstead; - Rename
ColumnSchemaInterfacetoColumnInterface.
Add ColumnInterface support and change type of parameter $type to ColumnInterface|string
in the following methods:
addColumn()alterColumn()
in classes that implement the following interfaces:
Yiisoft\Db\Command\CommandInterface;Yiisoft\Db\QueryBuilder\DDLQueryBuilderInterface;
or inherit from the following classes:
Yiisoft\Db\Command\AbstractCommand;Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder;Yiisoft\Db\QueryBuilder\AbstractQueryBuilder.
Change $columns parameter type from array|string|ExpressionInterface to array|bool|float|int|string|ExpressionInterface
in methods select() and addSelect() of your classes that implement Yiisoft\Db\Query\QueryPartsInterface.
Add support any scalar values for $columns parameter of these methods in your classes that implement
Yiisoft\Db\Query\QueryPartsInterface or inherit Yiisoft\Db\Query\Query.
ExpressionBuilder is replaced by an abstract class AbstractExpressionBuilder with an instance of the
QueryBuilderInterface parameter in the constructor. Each DBMS driver should implement its own expression builder.
Expression::$params can contain:
- non-unique placeholder names, they will be replaced with unique names;
Expressioninstances, they will be built when building a query usingQueryBuilder.
batchInsert() method is renamed to insertBatch() in DMLQueryBuilderInterface and CommandInterface.
The parameters are changed from $table, $columns, $rows to $table, $rows, $columns = [].
It allows to use the method without columns, for example:
use Yiisoft\Db\Connection\ConnectionInterface;
$values = [
['name' => 'Tom', 'age' => 30],
['name' => 'Jane', 'age' => 20],
['name' => 'Linda', 'age' => 25],
];
/** @var ConnectionInterface $db */
$db->createCommand()->insertBatch('user', $values)->execute();Rename ColumnSchemaInterface to ColumnInterface.
The interface and the abstract implementation AbstractColumn were moved to Yiisoft\Db\Schema\Column namespace
and the following changes were made:
getName()method can returnstringornull;getPhpType()method must returnstringPHP type of the column which used for generating related model properties;withName(string|null $name)method is added;check(string|null $check)method is added;getCheck()method is added;reference(ForeignKeyConstraint|null $reference)method is added;getReference()method is added;notNull(bool $notNull = true)method is added;null()method is added;isNotNull()method is added;unique(bool $unique = true)method is added;isUnique()method is added;hasDefaultValue()method is added;- all
AbstractColumnclass properties except$typemoved to constructor; - added
DEFAULT_TYPEconstant toAbstractColumnclass; - added method chaining.
Yiisoft\Db\Constant\PhpTypewith PHP types constants;Yiisoft\Db\Constant\GettypeResultwithgettype()function results constants;Yiisoft\Db\Constant\ColumnTypewith abstract column types constants;Yiisoft\Db\Constant\PseudoTypewith column pseudo-types constants;Yiisoft\Db\Constant\IndexTypewith table index types;Yiisoft\Db\Constant\ReferentialActionwith possible values of referential actions.
Each table column has its own class in the Yiisoft\Db\Schema\Column namespace according to the data type:
BooleanColumnfor columns with boolean type;BitColumnfor columns with bit type;IntegerColumnfor columns with integer type (tinyint, smallint, integer, bigint);BigIntColumnfor columns with integer type with range outsidePHP_INT_MINandPHP_INT_MAX;DoubleColumnfor columns with fractional number type (float, double, decimal, money);StringColumnfor columns with string type (char, string, text);BinaryColumnfor columns with binary type;DateTimeColumnfor columns with date and time type (timestamp, datetime, time, date);ArrayColumnfor columns with array type;StructuredColumnfor columns with structured type (composite type in PostgreSQL);JsonColumnfor columns with json type.
QuoterInterface::getRawTableName()- returns the raw table name without quotes;QueryInterface::resultCallback()- allows to use a callback, to be called on all rows of the query result;QueryInterface::getFor()- returns theFORpart of the query;QueryInterface::getResultCallback()- returns the callback to be called on all rows of the query result ornullif the callback is not set;QueryInterface::withTypecasting()- enables or disables typecasting of values when retrieving records from DB;QueryPartsInterface::for()- sets theFORpart of the query;QueryPartsInterface::addFor()- adds moreFORparts to the existing ones;QueryPartsInterface::setFor()- overwrites theFORpart of the query;QueryPartsInterface::setWhere()- overwrites theWHEREpart of the query;QueryPartsInterface::setHaving()- overwrites theHAVINGpart of the query;ConnectionInterface::getColumnFactory()- returns the column factory object for concrete DBMS;ConnectionInterface::getServerInfo()- returnsServerInfoInterfaceinstance which provides server information;ConnectionInterface::createQuery()- creates aQueryobject;ConnectionInterface::select()- creates aQueryobject with the specified columns to be selected;QueryBuilderInterface::buildColumnDefinition()- builds column definition forCREATE TABLEstatement;QueryBuilderInterface::buildValue()- converts a value to its SQL representation with binding parameters if necessary;QueryBuilderInterface::prepareParam()- converts aParamInterfaceobject to its SQL representation;QueryBuilderInterface::prepareValue()- converts a value to its SQL representation;QueryBuilderInterface::replacePlaceholders()- replaces placeholders in the SQL string with the corresponding values;QueryBuilderInterface::getColumnFactory()- returns the column factory object for concrete DBMS;QueryBuilderInterface::getServerInfo()- returnsServerInfoInterfaceinstance which provides server information;DQLQueryBuilderInterface::buildFor()- builds a SQL forFORclause;DMLQueryBuilderInterface::isTypecastingEnabled()- returns whether typecasting is enabled for the query builder;DMLQueryBuilderInterface::upsertReturning()- builds a SQL to insert or update a record with returning values;DMLQueryBuilderInterface::withTypecasting()- enables or disables typecasting of values when inserting or updating records in DB;LikeConditionInterface::getCaseSensitive()- returns whether the comparison is case-sensitive;SchemaInterface::hasTable()- returns whether the specified table exists in database;SchemaInterface::hasSchema()- returns whether the specified schema exists in database;SchemaInterface::hasView()- returns whether the specified view exists in database;DbArrayHelper::arrange()- arranges an array by specified keys;CommandInterface::upsertReturning()- inserts or updates a record returning its values;CommandInterface::upsertReturningPks()- inserts or updates a record returning its primary keys;CommandInterface::withDbTypecasting()- enables or disables typecasting of values when inserting or updating records;CommandInterface::withPhpTypecasting()- enables or disables typecasting of values when retrieving records from DB;CommandInterface::withTypecasting()- enables or disables typecasting of values when inserting, updating or retrieving records from DB;SchemaInterface::getResultColumn()- returns the column instance for the column metadata received from the query;AbstractSchema::getResultColumnCacheKey()- returns the cache key for the column metadata received from the query;AbstractSchema::loadResultColumn()- creates a new column instance according to the column metadata from the query;
AbstractQueryBuilder::getColumnType()- useAbstractQueryBuilder::buildColumnDefinition()instead;AbstractDMLQueryBuilder::getTypecastValue();TableSchemaInterface::compositeForeignKey();SchemaInterface::createColumn()- useColumnBuilderinstead;SchemaInterface::isReadQuery()- useDbStringHelper::isReadQuery()instead;SchemaInterface::getRawTableName()- useQuoterInterface::getRawTableName()instead;AbstractSchema::isReadQuery()- useDbStringHelper::isReadQuery()instead;AbstractSchema::getRawTableName()- useQuoterInterface::getRawTableName()instead;AbstractSchema::normalizeRowKeyCase()- usearray_change_key_case()instead;Quoter::unquoteParts();AbstractPdoCommand::logQuery();ColumnSchemaInterface::phpType();ConnectionInterface::getServerVersion()- useConnectionInterface::getServerInfo()instead;DbArrayHelper::getColumn()- usearray_column()instead;DbArrayHelper::getValueByPath();DbArrayHelper::populate()- useDbArrayHelper::index()instead;DbStringHelper::baseName();DbStringHelper::pascalCaseToId();AbstractDQLQueryBuilder::hasLimit()- use$limit !== nullinstead;AbstractDQLQueryBuilder::hasOffset()- use!empty($offset)instead;BatchQueryResultInterface::reset()- useBatchQueryResultInterface::rewind()instead;BatchQueryResult::reset()- useBatchQueryResult::rewind()instead;
$tablefromAbstractDMLQueryBuilder::normalizeColumnNames()method$tablefromAbstractDMLQueryBuilder::getNormalizeColumnNames()method$withColumnfromQuoterInterface::getTableNameParts()method$rawSqlfromAbstractCommand::internalExecute()method$rawSqlfromAbstractPdoCommand::internalExecute()method
SchemaInterface::TYPE_JSONBSchemaInterface::PHP_TYPE_INTEGERSchemaInterface::PHP_TYPE_STRINGSchemaInterface::PHP_TYPE_BOOLEANSchemaInterface::PHP_TYPE_DOUBLESchemaInterface::PHP_TYPE_RESOURCESchemaInterface::PHP_TYPE_ARRAYSchemaInterface::PHP_TYPE_NULL
- Allow
ExpressionInterfacefor$aliasparameter ofQueryPartsInterface::withQuery()method; - Allow
QueryInterface::one()to return an object; - Allow
QueryInterface::all()to return array of objects; - Add parameters
$ifExistsand$cascadetoCommandInterface::dropTable()andDDLQueryBuilderInterface::dropTable()methods. - Change
Quoter::quoteValue()parameter type and return type frommixedtostring; - Move
DataTypeclass toYiisoft\Db\Constantnamespace; - Change
DbArrayHelper::index()parameter names and allow to acceptClosurefor$indexByparameter; - Change return type of
CommandInterface::insertWithReturningPks()method toarray|false; - Change return type of
AbstractCommand::insertWithReturningPks()method toarray|false; - Rename
QueryBuilderInterface::quoter()method toQueryBuilderInterface::getQuoter(); - Change constructor parameters in
AbstractQueryBuilderclass; - Remove nullable from
PdoConnectionInterface::getActivePdo()result; - Move
Yiisoft\Db\Query\Data\DataReaderInterfaceinterface toYiisoft\Db\Querynamespace; - Move
Yiisoft\Db\Query\Data\DataReaderclass toYiisoft\Db\Driver\Pdonamespace and rename it toPdoDataReader; - Add
indexBy()andresultCallback()methods toDataReaderInterfaceandPdoDataReaderclass; - Change return type of
DataReaderInterface::key()method toint|string|null; - Change return type of
DataReaderInterface::current()method toarray|object|false; - Change
PdoDataReadera constructor parameter; - Remove the second parameter
$eachfromConnectionInterface::createBatchQueryResult()andAbstractConnection::createBatchQueryResult()methods; - Rename
setPopulatedMethod()toresultCallback()inBatchQueryResultInterfaceandBatchQueryResultclass; - Change return type of
key()method tointinBatchQueryResultInterfaceandBatchQueryResultclass; - Change return type of
current()method toarrayinBatchQueryResultInterfaceandBatchQueryResultclass; - Remove
nullfrom return type ofgetQuery()method inBatchQueryResultInterfaceandBatchQueryResultclass; - Remove parameters from
each()method inQueryInterfaceandQueryclass; - Change return type of
each()method toDataReaderInterfaceinQueryInterfaceandQueryclass; - Add
$columnFactoryparameter toAbstractPdoConnection::__construct()constructor; - Change
Query::$distincttype toboolwithfalseas default value; - Change
QueryInterface::getDistinct()result type tobool; - Change
QueryPartsInterface::distinct()parameter type tobool; - Change
$distinctparameter type inDQLQueryBuilderInterface::buildSelect()tobool; - Add
QueryInterfaceto type of$columnsparameter ofinsertWithReturningPks()method inCommandInterfaceandAbstractCommandclass; - Rename
insertWithReturningPks()toinsertReturningPks()method inCommandInterfaceandDMLQueryBuilderInterface; - Remove
$paramsparameter fromupsert()method inCommandInterfaceandAbstractCommandclass; - Add default value to
$updateColumnsand$paramsparameters ofupsert()method inDMLQueryBuilderInterfaceandAbstractDMLQueryBuilderandAbstractQueryBuilderclasses;