Browse Source

Added typecast database types into php types

tags/2.0.0-beta
Vladimir Zbrailov 11 years ago
parent
commit
903f5618fe
  1. 1
      framework/CHANGELOG.md
  2. 3
      framework/db/BaseActiveRecord.php

1
framework/CHANGELOG.md

@ -115,6 +115,7 @@ Yii Framework 2 Change Log
- Enh: Added `yii\web\View::POS_LOAD` (qiangxue)
- Enh: Added `yii\web\Response::clearOutputBuffers()` (qiangxue)
- Enh: Improved `QueryBuilder::buildLimit()` to support big numbers (qiangxue)
- Enh: Added typecast database types into php types (dizews)
- Enh #2240: Improved `yii\web\AssetManager::publish()`, `yii\web\AssetManager::getPublishedPath()` and `yii\web\AssetManager::getPublishedUrl()` to support aliases (vova07)
- Chg #1519: `yii\web\User::loginRequired()` now returns the `Response` object instead of exiting the application (qiangxue)
- Chg #1586: `QueryBuilder::buildLikeCondition()` will now escape special characters and use percentage characters by default (qiangxue)

3
framework/db/BaseActiveRecord.php

@ -1002,8 +1002,11 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
{
$record = static::instantiate($row);
$columns = array_flip($record->attributes());
/* @var $schema TableSchema */
$schema = static::getDb()->getTableSchema(static::tableName());
foreach ($row as $name => $value) {
if (isset($columns[$name])) {
$value = $schema->getColumn($name)->typecast($value);
$record->_attributes[$name] = $value;
} else {
$record->$name = $value;

Loading…
Cancel
Save