mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-21 00:54:53 +08:00
Merge pull request #2263 from dizews/convert-database-type-to-php
Convert database type to php
This commit is contained in:
@@ -115,6 +115,7 @@ Yii Framework 2 Change Log
|
|||||||
- Enh: Added `yii\web\View::POS_LOAD` (qiangxue)
|
- Enh: Added `yii\web\View::POS_LOAD` (qiangxue)
|
||||||
- Enh: Added `yii\web\Response::clearOutputBuffers()` (qiangxue)
|
- Enh: Added `yii\web\Response::clearOutputBuffers()` (qiangxue)
|
||||||
- Enh: Improved `QueryBuilder::buildLimit()` to support big numbers (qiangxue)
|
- Enh: Improved `QueryBuilder::buildLimit()` to support big numbers (qiangxue)
|
||||||
|
- Enh:#2211: 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)
|
- 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 #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)
|
- Chg #1586: `QueryBuilder::buildLikeCondition()` will now escape special characters and use percentage characters by default (qiangxue)
|
||||||
|
|||||||
@@ -274,6 +274,29 @@ class ActiveRecord extends BaseActiveRecord
|
|||||||
return new ActiveRelation($config);
|
return new ActiveRelation($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritdoc
|
||||||
|
*/
|
||||||
|
public static function create($row)
|
||||||
|
{
|
||||||
|
$record = static::instantiate($row);
|
||||||
|
$columns = array_flip($record->attributes());
|
||||||
|
$schema = static::getTableSchema();
|
||||||
|
foreach ($row as $name => $value) {
|
||||||
|
if (isset($columns[$name])) {
|
||||||
|
if ($schema->getColumn($name) !== null) {
|
||||||
|
$record->setAttribute($name, $schema->getColumn($name)->typecast($value));
|
||||||
|
} else {
|
||||||
|
$record->setAttribute($name, $value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$record->$name = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$record->setOldAttributes($record->getAttributes());
|
||||||
|
return $record;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a row into the associated database table using the attribute values of this record.
|
* Inserts a row into the associated database table using the attribute values of this record.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user