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
91e6f822
Commit
91e6f822
authored
May 07, 2013
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a5ab4aa2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
upgrade-from-v1.md
docs/guide/upgrade-from-v1.md
+13
-13
No files found.
docs/guide/upgrade-from-v1.md
View file @
91e6f822
...
@@ -71,7 +71,7 @@ $object = Yii::createObject(array(
...
@@ -71,7 +71,7 @@ $object = Yii::createObject(array(
'property2'
=>
'cde'
,
'property2'
=>
'cde'
,
),
$param1
,
$param2
);
),
$param1
,
$param2
);
```
```
~~~
Events
Events
...
@@ -86,7 +86,7 @@ $component->on($eventName, $handler);
...
@@ -86,7 +86,7 @@ $component->on($eventName, $handler);
// To detach the handler, use:
// To detach the handler, use:
// $component->off($eventName, $handler);
// $component->off($eventName, $handler);
```
```
~~~
When you attach a handler, you can now associate it with some parameters which can be later
When you attach a handler, you can now associate it with some parameters which can be later
accessed via the event parameter by the handler:
accessed via the event parameter by the handler:
...
@@ -94,7 +94,7 @@ accessed via the event parameter by the handler:
...
@@ -94,7 +94,7 @@ accessed via the event parameter by the handler:
```
php
```
php
$component
->
on
(
$eventName
,
$handler
,
$params
);
$component
->
on
(
$eventName
,
$handler
,
$params
);
```
```
~~~
Because of this change, you can now use "global" events. Simply trigger and attach handlers to
Because of this change, you can now use "global" events. Simply trigger and attach handlers to
an event of the application instance:
an event of the application instance:
...
@@ -144,7 +144,7 @@ $content = Yii::$app->view->renderFile($viewFile, $params);
...
@@ -144,7 +144,7 @@ $content = Yii::$app->view->renderFile($viewFile, $params);
// $view = new View;
// $view = new View;
// $view->renderFile($viewFile, $params);
// $view->renderFile($viewFile, $params);
```
```
~~~
Also, there is no more
`CClientScript`
in Yii 2.0. The
`View`
class has taken over its role
Also, there is no more
`CClientScript`
in Yii 2.0. The
`View`
class has taken over its role
with significant improvements. For more details, please see the "assets" subsection.
with significant improvements. For more details, please see the "assets" subsection.
...
@@ -178,7 +178,7 @@ public function scenarios()
...
@@ -178,7 +178,7 @@ public function scenarios()
);
);
}
}
```
```
~~~
This method also determines which attributes are safe and which are not. In particular,
This method also determines which attributes are safe and which are not. In particular,
given a scenario, if an attribute appears in the corresponding attribute list in
`scenarios()`
given a scenario, if an attribute appears in the corresponding attribute list in
`scenarios()`
...
@@ -207,7 +207,7 @@ if (isset($_POST['Post'])) {
...
@@ -207,7 +207,7 @@ if (isset($_POST['Post'])) {
$post
->
attributes
=
$_POST
[
'Post'
];
$post
->
attributes
=
$_POST
[
'Post'
];
}
}
```
```
~~~
Themes
Themes
...
@@ -276,7 +276,7 @@ public function behaviors()
...
@@ -276,7 +276,7 @@ public function behaviors()
);
);
}
}
```
```
~~~
Assets
Assets
...
@@ -317,7 +317,7 @@ as an `ActiveField` object. Using fields, you can build a form more cleanly than
...
@@ -317,7 +317,7 @@ as an `ActiveField` object. Using fields, you can build a form more cleanly than
</div>
</div>
<?php
$this
->
endWidget
();
?>
<?php
$this
->
endWidget
();
?>
```
```
~~~
Query Builder
Query Builder
...
@@ -337,7 +337,7 @@ $command = $query->createCommand();
...
@@ -337,7 +337,7 @@ $command = $query->createCommand();
$sql
=
$command
->
sql
;
$sql
=
$command
->
sql
;
$rows
=
$command
->
queryAll
();
$rows
=
$command
->
queryAll
();
```
```
~~~
Best of all, such query building methods can be used together with
`ActiveRecord`
,
Best of all, such query building methods can be used together with
`ActiveRecord`
,
as explained in the next sub-section.
as explained in the next sub-section.
...
@@ -360,7 +360,7 @@ class Customer extends \yii\db\ActiveRecord
...
@@ -360,7 +360,7 @@ class Customer extends \yii\db\ActiveRecord
}
}
}
}
```
```
~~~
You can use
`$customer->orders`
to access the customer's orders. You can also
You can use
`$customer->orders`
to access the customer's orders. You can also
use
`$customer->getOrders()->andWhere('status=1')->all()`
to perform on-the-fly
use
`$customer->getOrders()->andWhere('status=1')->all()`
to perform on-the-fly
...
@@ -385,7 +385,7 @@ $customers = Customer::find()
...
@@ -385,7 +385,7 @@ $customers = Customer::find()
// return the customer whose PK is 1
// return the customer whose PK is 1
$customer
=
Customer
::
find
(
1
);
$customer
=
Customer
::
find
(
1
);
```
```
~~~
The
`find()`
method returns an instance of
`ActiveQuery`
which is a subclass of
`Query`
.
The
`find()`
method returns an instance of
`ActiveQuery`
which is a subclass of
`Query`
.
Therefore, you can use all query methods of
`Query`
.
Therefore, you can use all query methods of
`Query`
.
...
@@ -415,7 +415,7 @@ the database driver being used. For example,
...
@@ -415,7 +415,7 @@ the database driver being used. For example,
$command
=
$connection
->
createCommand
(
'SELECT [[id]] FROM {{posts}}'
);
$command
=
$connection
->
createCommand
(
'SELECT [[id]] FROM {{posts}}'
);
echo
$command
->
sql
;
// MySQL: SELECT `id` FROM `posts`
echo
$command
->
sql
;
// MySQL: SELECT `id` FROM `posts`
```
```
~~~
This feature is especially useful if you are developing an application that supports
This feature is especially useful if you are developing an application that supports
different DBMS.
different DBMS.
...
@@ -443,7 +443,7 @@ array(
...
@@ -443,7 +443,7 @@ array(
'defaults'
=>
array
(
'page'
=>
1
),
'defaults'
=>
array
(
'page'
=>
1
),
)
)
```
```
~~~
Response
Response
...
...
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