Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
39b0c454
Commit
39b0c454
authored
Mar 19, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default values init moved to a method that should be called manually
parent
b66427f8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
CHANGELOG.md
framework/CHANGELOG.md
+1
-1
ActiveRecord.php
framework/db/ActiveRecord.php
+5
-2
No files found.
framework/CHANGELOG.md
View file @
39b0c454
...
@@ -146,7 +146,7 @@ Yii Framework 2 Change Log
...
@@ -146,7 +146,7 @@ Yii Framework 2 Change Log
-
Enh #2661: Added boolean column type support for SQLite (qiangxue)
-
Enh #2661: Added boolean column type support for SQLite (qiangxue)
-
Enh #2670: Changed
`console\Controller::globalOptions()`
to
`options($actionId)`
to (make it possible to) differentiate options per action (hqx)
-
Enh #2670: Changed
`console\Controller::globalOptions()`
to
`options($actionId)`
to (make it possible to) differentiate options per action (hqx)
-
Enh #2714: Added support for formatting time intervals relative to the current time with
`yii\base\Formatter`
(drenty)
-
Enh #2714: Added support for formatting time intervals relative to the current time with
`yii\base\Formatter`
(drenty)
-
Enh #2726: A
ctiveRecord now fills default values on creating new instance of the model if defaults are available
from DB schema (samdark)
-
Enh #2726: A
dded
`yii\db\ActiveRecord::loadDefaultValues()`
that fills default values
from DB schema (samdark)
-
Enh #2729: Added
`FilterValidator::skipOnArray`
so that filters like
`trim`
will not fail for array inputs (qiangxue)
-
Enh #2729: Added
`FilterValidator::skipOnArray`
so that filters like
`trim`
will not fail for array inputs (qiangxue)
-
Enh #2735: Added support for
`DateTimeInterface`
in
`Formatter`
(ivokund)
-
Enh #2735: Added support for
`DateTimeInterface`
in
`Formatter`
(ivokund)
-
Enh #2756: Added support for injecting custom
`isEmpty`
check for all validators (qiangxue)
-
Enh #2756: Added support for injecting custom
`isEmpty`
check for all validators (qiangxue)
...
...
framework/db/ActiveRecord.php
View file @
39b0c454
...
@@ -94,15 +94,18 @@ class ActiveRecord extends BaseActiveRecord
...
@@ -94,15 +94,18 @@ class ActiveRecord extends BaseActiveRecord
const
OP_ALL
=
0x07
;
const
OP_ALL
=
0x07
;
/**
/**
* @inheritdoc
* Loads default values from database table schema
*
* @return static model instance
*/
*/
public
function
init
()
public
function
loadDefaultValues
()
{
{
foreach
(
$this
->
getTableSchema
()
->
columns
as
$column
)
{
foreach
(
$this
->
getTableSchema
()
->
columns
as
$column
)
{
if
(
$column
->
defaultValue
)
{
if
(
$column
->
defaultValue
)
{
$this
->
{
$column
->
name
}
=
$column
->
defaultValue
;
$this
->
{
$column
->
name
}
=
$column
->
defaultValue
;
}
}
}
}
return
$this
;
}
}
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment