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
5c3e4fa4
Commit
5c3e4fa4
authored
Mar 19, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted unit tests, added description to docs
parent
39b0c454
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
active-record.md
docs/guide/active-record.md
+9
-0
ActiveRecordTest.php
tests/unit/framework/db/ActiveRecordTest.php
+1
-0
No files found.
docs/guide/active-record.md
View file @
5c3e4fa4
...
@@ -193,6 +193,15 @@ Customer::updateAllCounters(['age' => 1]);
...
@@ -193,6 +193,15 @@ Customer::updateAllCounters(['age' => 1]);
> Info: The `save()` method will either perform an `INSERT` or `UPDATE` SQL statement, depending
> Info: The `save()` method will either perform an `INSERT` or `UPDATE` SQL statement, depending
on whether the ActiveRecord being saved is new or not by checking
`ActiveRecord::isNewRecord`
.
on whether the ActiveRecord being saved is new or not by checking
`ActiveRecord::isNewRecord`
.
In order to load default values from database schema you may call
`loadDefaultValues()`
method:
```
php
$customer
=
new
Customer
();
$customer
->
loadDefaultValues
();
$cusomer
->
name
=
'Alexander'
;
$customer
->
save
();
```
Data Input and Validation
Data Input and Validation
-------------------------
-------------------------
...
...
tests/unit/framework/db/ActiveRecordTest.php
View file @
5c3e4fa4
...
@@ -491,6 +491,7 @@ class ActiveRecordTest extends DatabaseTestCase
...
@@ -491,6 +491,7 @@ class ActiveRecordTest extends DatabaseTestCase
public
function
testDefaultValues
()
public
function
testDefaultValues
()
{
{
$model
=
new
Type
();
$model
=
new
Type
();
$model
->
loadDefaultValues
();
$this
->
assertEquals
(
1
,
$model
->
int_col2
);
$this
->
assertEquals
(
1
,
$model
->
int_col2
);
$this
->
assertEquals
(
'something'
,
$model
->
char_col2
);
$this
->
assertEquals
(
'something'
,
$model
->
char_col2
);
$this
->
assertEquals
(
1.23
,
$model
->
float_col2
);
$this
->
assertEquals
(
1.23
,
$model
->
float_col2
);
...
...
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