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
ab27d16e
Commit
ab27d16e
authored
Jul 03, 2013
by
Sw3rtas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Fixed Model::loadMultiple() when populating from formName()
* Documentation corrections for data population and quoting names in SQL query
parent
223e259b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
15 deletions
+23
-15
database-basics.md
docs/guide/database-basics.md
+2
-2
upgrade-from-v1.md
docs/guide/upgrade-from-v1.md
+20
-12
Model.php
framework/yii/base/Model.php
+1
-1
No files found.
docs/guide/database-basics.md
View file @
ab27d16e
...
@@ -136,11 +136,11 @@ Quoting table and column names
...
@@ -136,11 +136,11 @@ Quoting table and column names
Most of the time you would use the following syntax for quoting table and column names:
Most of the time you would use the following syntax for quoting table and column names:
```
php
```
php
$sql
=
"SELECT COUNT(
{
{$column}
}
) FROM [[
$table
]]
"
;
$sql
=
"SELECT COUNT(
[[
$column
]]) FROM
{
{$table}
}
"
;
$rowCount
=
$connection
->
createCommand
(
$sql
)
->
queryScalar
();
$rowCount
=
$connection
->
createCommand
(
$sql
)
->
queryScalar
();
```
```
In the code above
`
{{X}}`
will be converted to properly quoted column name while
`[[Y]]
`
will be converted to properly
In the code above
`
[[X]]`
will be converted to properly quoted column name while
`{{Y}}
`
will be converted to properly
quoted table name.
quoted table name.
The alternative is to quote table and column names manually using
[
[\yii\db\Connection::quoteTableName()
]
] and
The alternative is to quote table and column names manually using
[
[\yii\db\Connection::quoteTableName()
]
] and
...
...
docs/guide/upgrade-from-v1.md
View file @
ab27d16e
...
@@ -163,6 +163,26 @@ A model is now associated with a form name returned by its `formName()` method.
...
@@ -163,6 +163,26 @@ A model is now associated with a form name returned by its `formName()` method.
mainly used when using HTML forms to collect user inputs for a model. Previously in 1.1,
mainly used when using HTML forms to collect user inputs for a model. Previously in 1.1,
this is usually hardcoded as the class name of the model.
this is usually hardcoded as the class name of the model.
A new methods called
`load()`
and
`Model::loadMultiple()`
is introduced to simplify the data population from user inputs
to a model. For example,
```
php
$model
=
new
Post
;
if
(
$model
->
load
(
$_POST
))
{
...
}
// which is equivalent to:
if
(
isset
(
$_POST
[
'Post'
]))
{
$model
->
attributes
=
$_POST
[
'Post'
];
}
$model
->
save
();
$postTags
=
array
();
$tagsCount
=
count
(
$_POST
[
'PostTag'
]);
while
(
$tagsCount
--
>
0
){
$postTags
[]
=
new
PostTag
(
array
(
'post_id'
=>
$model
->
id
));
}
Model
::
loadMultiple
(
$postTags
,
$_POST
);
```
Yii 2.0 introduces a new method called
`scenarios()`
to declare which attributes require
Yii 2.0 introduces a new method called
`scenarios()`
to declare which attributes require
validation under which scenario. Child classes should overwrite
`scenarios()`
to return
validation under which scenario. Child classes should overwrite
`scenarios()`
to return
...
@@ -196,18 +216,6 @@ Controllers
...
@@ -196,18 +216,6 @@ Controllers
The
`render()`
and
`renderPartial()`
methods now return the rendering results instead of directly
The
`render()`
and
`renderPartial()`
methods now return the rendering results instead of directly
sending them out. You have to
`echo`
them explicitly, e.g.,
`echo $this->render(...);`
.
sending them out. You have to
`echo`
them explicitly, e.g.,
`echo $this->render(...);`
.
A new method called
`populate()`
is introduced to simplify the data population from user inputs
to a model. For example,
```
php
$model
=
new
Post
;
if
(
$model
->
load
(
$_POST
))
{
...
}
// which is equivalent to:
if
(
isset
(
$_POST
[
'Post'
]))
{
$model
->
attributes
=
$_POST
[
'Post'
];
}
```
Widgets
Widgets
-------
-------
...
...
framework/yii/base/Model.php
View file @
ab27d16e
...
@@ -694,7 +694,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
...
@@ -694,7 +694,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
$success
=
true
;
$success
=
true
;
}
}
}
elseif
(
isset
(
$data
[
$scope
][
$i
]))
{
}
elseif
(
isset
(
$data
[
$scope
][
$i
]))
{
$model
->
setAttributes
(
$data
[
$scope
[
$i
]
]);
$model
->
setAttributes
(
$data
[
$scope
][
$i
]);
$success
=
true
;
$success
=
true
;
}
}
}
}
...
...
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