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
064da587
Commit
064da587
authored
Mar 01, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2591 from AlexGx/doc-codestyle-fix
fix doc code according to yii2 core code style
parents
6c0576af
c2ea7670
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
19 deletions
+19
-19
active-record.md
docs/guide/active-record.md
+2
-2
controller.md
docs/guide/controller.md
+1
-1
data-providers.md
docs/guide/data-providers.md
+2
-2
model.md
docs/guide/model.md
+4
-4
query-builder.md
docs/guide/query-builder.md
+7
-7
upgrade-from-v1.md
docs/guide/upgrade-from-v1.md
+3
-3
No files found.
docs/guide/active-record.md
View file @
064da587
...
@@ -172,7 +172,7 @@ Note that [[yii\db\ActiveRecord::updateAll()|updateAll()]], [[yii\db\ActiveRecor
...
@@ -172,7 +172,7 @@ Note that [[yii\db\ActiveRecord::updateAll()|updateAll()]], [[yii\db\ActiveRecor
```
php
```
php
// to insert a new customer record
// to insert a new customer record
$customer
=
new
Customer
;
$customer
=
new
Customer
()
;
$customer
->
name
=
'James'
;
$customer
->
name
=
'James'
;
$customer
->
email
=
'james@example.com'
;
$customer
->
email
=
'james@example.com'
;
$customer
->
save
();
// equivalent to $customer->insert();
$customer
->
save
();
// equivalent to $customer->insert();
...
@@ -634,7 +634,7 @@ order owned by the customer:
...
@@ -634,7 +634,7 @@ order owned by the customer:
```
php
```
php
$customer
=
Customer
::
find
(
1
);
$customer
=
Customer
::
find
(
1
);
$order
=
new
Order
;
$order
=
new
Order
()
;
$order
->
subtotal
=
100
;
$order
->
subtotal
=
100
;
$customer
->
link
(
'orders'
,
$order
);
$customer
->
link
(
'orders'
,
$order
);
```
```
...
...
docs/guide/controller.md
View file @
064da587
...
@@ -160,7 +160,7 @@ class BlogController extends Controller
...
@@ -160,7 +160,7 @@ class BlogController extends Controller
{
{
$post
=
Post
::
find
(
$id
);
$post
=
Post
::
find
(
$id
);
if
(
!
$post
)
{
if
(
!
$post
)
{
throw
new
NotFoundHttpException
;
throw
new
NotFoundHttpException
()
;
}
}
if
(
\Yii
::
$app
->
request
->
isPost
)
{
if
(
\Yii
::
$app
->
request
->
isPost
)
{
...
...
docs/guide/data-providers.md
View file @
064da587
...
@@ -29,7 +29,7 @@ $posts = $provider->getModels();
...
@@ -29,7 +29,7 @@ $posts = $provider->getModels();
And
the
following
example
shows
how
to
use
ActiveDataProvider
without
ActiveRecord
:
And
the
following
example
shows
how
to
use
ActiveDataProvider
without
ActiveRecord
:
```
php
```
php
$query = new Query;
$query = new Query
()
;
$provider = new ActiveDataProvider(
[
$provider = new ActiveDataProvider(
[
'query' => $query->from('tbl_post'),
'query' => $query->from('tbl_post'),
'pagination' =>
[
'pagination' =>
[
...
@@ -62,7 +62,7 @@ because it needs to have [[allModels]] ready.
...
@@ -62,7 +62,7 @@ because it needs to have [[allModels]] ready.
ArrayDataProvider may be used in the following way:
ArrayDataProvider may be used in the following way:
```
php
```
php
$query = new Query;
$query = new Query
()
;
$provider = new ArrayDataProvider(
[
$provider = new ArrayDataProvider(
[
'allModels' => $query->from('tbl_post')->all(),
'allModels' => $query->from('tbl_post')->all(),
'sort' =>
[
'sort' =>
[
...
...
docs/guide/model.md
View file @
064da587
...
@@ -24,7 +24,7 @@ be accessed like the member variables of any object. For example, a `Post` model
...
@@ -24,7 +24,7 @@ be accessed like the member variables of any object. For example, a `Post` model
may contain a
`title`
attribute and a
`content`
attribute, accessible as follows:
may contain a
`title`
attribute and a
`content`
attribute, accessible as follows:
```
php
```
php
$post
=
new
Post
;
$post
=
new
Post
()
;
$post
->
title
=
'Hello, world'
;
$post
->
title
=
'Hello, world'
;
$post
->
content
=
'Something interesting is happening.'
;
$post
->
content
=
'Something interesting is happening.'
;
echo
$post
->
title
;
echo
$post
->
title
;
...
@@ -35,7 +35,7 @@ Since [[yii\base\Model|Model]] implements the [ArrayAccess](http://php.net/manua
...
@@ -35,7 +35,7 @@ Since [[yii\base\Model|Model]] implements the [ArrayAccess](http://php.net/manua
you can also access the attributes as if they were array elements:
you can also access the attributes as if they were array elements:
```
php
```
php
$post
=
new
Post
;
$post
=
new
Post
()
;
$post
[
'title'
]
=
'Hello, world'
;
$post
[
'title'
]
=
'Hello, world'
;
$post
[
'content'
]
=
'Something interesting is happening'
;
$post
[
'content'
]
=
'Something interesting is happening'
;
echo
$post
[
'title'
];
echo
$post
[
'title'
];
...
@@ -160,7 +160,7 @@ class EmployeeController extends \yii\web\Controller
...
@@ -160,7 +160,7 @@ class EmployeeController extends \yii\web\Controller
$employee
=
new
Employee
([
'scenario'
=>
'managementPanel'
]);
$employee
=
new
Employee
([
'scenario'
=>
'managementPanel'
]);
// second way
// second way
$employee
=
new
Employee
;
$employee
=
new
Employee
()
;
$employee
->
scenario
=
'managementPanel'
;
$employee
->
scenario
=
'managementPanel'
;
// third way
// third way
...
@@ -187,7 +187,7 @@ only, etc. If errors are found in validation, they may be presented to the user
...
@@ -187,7 +187,7 @@ only, etc. If errors are found in validation, they may be presented to the user
The following example shows how the validation is performed:
The following example shows how the validation is performed:
```
php
```
php
$model
=
new
LoginForm
;
$model
=
new
LoginForm
()
;
$model
->
username
=
$_POST
[
'username'
];
$model
->
username
=
$_POST
[
'username'
];
$model
->
password
=
$_POST
[
'password'
];
$model
->
password
=
$_POST
[
'password'
];
if
(
$model
->
validate
())
{
if
(
$model
->
validate
())
{
...
...
docs/guide/query-builder.md
View file @
064da587
...
@@ -9,7 +9,7 @@ The Query Builder provides an object-oriented vehicle for generating queries to
...
@@ -9,7 +9,7 @@ The Query Builder provides an object-oriented vehicle for generating queries to
A typical usage of the query builder looks like the following:
A typical usage of the query builder looks like the following:
```
php
```
php
$rows
=
(
new
\yii\db\Query
)
$rows
=
(
new
\yii\db\Query
()
)
->
select
(
'id, name'
)
->
select
(
'id, name'
)
->
from
(
'tbl_user'
)
->
from
(
'tbl_user'
)
->
limit
(
10
)
->
limit
(
10
)
...
@@ -17,7 +17,7 @@ $rows = (new \yii\db\Query)
...
@@ -17,7 +17,7 @@ $rows = (new \yii\db\Query)
// which is equivalent to the following code:
// which is equivalent to the following code:
$query
=
(
new
\yii\db\Query
)
$query
=
(
new
\yii\db\Query
()
)
->
select
(
'id, name'
)
->
select
(
'id, name'
)
->
from
(
'tbl_user'
)
->
from
(
'tbl_user'
)
->
limit
(
10
);
->
limit
(
10
);
...
@@ -116,7 +116,7 @@ You may specify a sub-query using a `Query` object. In this case, the correspond
...
@@ -116,7 +116,7 @@ You may specify a sub-query using a `Query` object. In this case, the correspond
as the alias for the sub-query.
as the alias for the sub-query.
```
php
```
php
$subQuery
=
(
new
Query
)
->
select
(
'id'
)
->
from
(
'tbl_user'
)
->
where
(
'status=1'
);
$subQuery
=
(
new
Query
()
)
->
select
(
'id'
)
->
from
(
'tbl_user'
)
->
where
(
'status=1'
);
$query
->
select
(
'*'
)
->
from
([
'u'
=>
$subQuery
]);
$query
->
select
(
'*'
)
->
from
([
'u'
=>
$subQuery
]);
```
```
...
@@ -324,10 +324,10 @@ $query->leftJoin(['u' => $subQuery], 'u.id=author_id');
...
@@ -324,10 +324,10 @@ $query->leftJoin(['u' => $subQuery], 'u.id=author_id');
In Yii in order to build it you can first form two query objects and then use `union` method:
In Yii in order to build it you can first form two query objects and then use `union` method:
```
php
```
php
$query = new Query;
$query = new Query
()
;
$query->select("id, 'post' as type, name")->from('tbl_post')->limit(10);
$query->select("id, 'post' as type, name")->from('tbl_post')->limit(10);
$anotherQuery = new Query;
$anotherQuery = new Query
()
;
$anotherQuery->select('id, 'user' as type, name')->from('tbl_user')->limit(10);
$anotherQuery->select('id, 'user' as type, name')->from('tbl_user')->limit(10);
$query->union($anotherQuery);
$query->union($anotherQuery);
...
@@ -347,7 +347,7 @@ Batch query can be used like the following:
...
@@ -347,7 +347,7 @@ Batch query can be used like the following:
```
php
```
php
use yii
\d
b
\Q
uery;
use yii
\d
b
\Q
uery;
$query = (new Query)
$query = (new Query
()
)
->from('tbl_user')
->from('tbl_user')
->orderBy('id');
->orderBy('id');
...
@@ -376,7 +376,7 @@ will still keep the proper index. For example,
...
@@ -376,7 +376,7 @@ will still keep the proper index. For example,
```
php
```
php
use yii
\d
b
\Q
uery;
use yii
\d
b
\Q
uery;
$query = (new Query)
$query = (new Query
()
)
->from('tbl_user')
->from('tbl_user')
->indexBy('username');
->indexBy('username');
...
...
docs/guide/upgrade-from-v1.md
View file @
064da587
...
@@ -158,7 +158,7 @@ in controllers or widgets:
...
@@ -158,7 +158,7 @@ in controllers or widgets:
```
php
```
php
$content
=
Yii
::
$app
->
view
->
renderFile
(
$viewFile
,
$params
);
$content
=
Yii
::
$app
->
view
->
renderFile
(
$viewFile
,
$params
);
// You can also explicitly create a new View instance to do the rendering
// You can also explicitly create a new View instance to do the rendering
// $view = new View;
// $view = new View
()
;
// $view->renderFile($viewFile, $params);
// $view->renderFile($viewFile, $params);
```
```
...
@@ -186,7 +186,7 @@ New methods called [[yii\base\Model::load()|load()] and [[yii\base\Model::loadMu
...
@@ -186,7 +186,7 @@ New methods called [[yii\base\Model::load()|load()] and [[yii\base\Model::loadMu
introduced to simplify the data population from user inputs to a model. For example,
introduced to simplify the data population from user inputs to a model. For example,
```
php
```
php
$model
=
new
Post
;
$model
=
new
Post
()
;
if
(
$model
->
load
(
$_POST
))
{
...
}
if
(
$model
->
load
(
$_POST
))
{
...
}
// which is equivalent to:
// which is equivalent to:
if
(
isset
(
$_POST
[
'Post'
]))
{
if
(
isset
(
$_POST
[
'Post'
]))
{
...
@@ -394,7 +394,7 @@ In 1.1, query building is scattered among several classes, including `CDbCommand
...
@@ -394,7 +394,7 @@ In 1.1, query building is scattered among several classes, including `CDbCommand
and
[
[yii\db\QueryBuilder|QueryBuilder
]
] to generate SQL statements from query objects. For example:
and
[
[yii\db\QueryBuilder|QueryBuilder
]
] to generate SQL statements from query objects. For example:
```
php
```
php
$query
=
new
\yii\db\Query
;
$query
=
new
\yii\db\Query
()
;
$query
->
select
(
'id, name'
)
$query
->
select
(
'id, name'
)
->
from
(
'tbl_user'
)
->
from
(
'tbl_user'
)
->
limit
(
10
);
->
limit
(
10
);
...
...
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