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
d5d241e8
Commit
d5d241e8
authored
Feb 01, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.yiisoft.com:yii2
parents
25e82b3d
da0ef127
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
24 deletions
+21
-24
Component.md
docs/api/base/Component.md
+2
-2
Object.md
docs/api/base/Object.md
+0
-3
ActiveRecord.md
docs/api/db/ActiveRecord.md
+7
-7
model.md
docs/model.md
+2
-2
View.php
framework/console/View.php
+0
-0
ActiveRecord.php
framework/db/ActiveRecord.php
+10
-10
No files found.
docs/api/base/Component.md
View file @
d5d241e8
...
@@ -7,7 +7,7 @@ is triggered (i.e. comment will be added), our custom code will be executed.
...
@@ -7,7 +7,7 @@ is triggered (i.e. comment will be added), our custom code will be executed.
An event is identified by a name that should be unique within the class it is defined at. Event names are
*case-sensitive*
.
An event is identified by a name that should be unique within the class it is defined at. Event names are
*case-sensitive*
.
One or multiple PHP callbacks, called
*event handlers*
, could be attached to event. You can call
[
[trigger()
]
] to
One or multiple PHP callbacks, called
*event handlers*
, could be attached to
an
event. You can call
[
[trigger()
]
] to
raise an event. When an event is raised, the event handlers will be invoked automatically in the order they were
raise an event. When an event is raised, the event handlers will be invoked automatically in the order they were
attached.
attached.
...
@@ -24,7 +24,7 @@ Valid event handlers include:
...
@@ -24,7 +24,7 @@ Valid event handlers include:
-
anonymous function:
`function($event) { ... }`
-
anonymous function:
`function($event) { ... }`
-
object method:
`array($object, 'handleAdd')`
-
object method:
`array($object, 'handleAdd')`
-
static method:
`array('Page', 'handleAdd')`
-
static
class
method:
`array('Page', 'handleAdd')`
-
global function:
`'handleAdd'`
-
global function:
`'handleAdd'`
The signature of an event handler should be like the following:
The signature of an event handler should be like the following:
...
...
docs/api/base/Object.md
View file @
d5d241e8
...
@@ -31,6 +31,3 @@ If a property has only a getter method and has no setter method, it is considere
...
@@ -31,6 +31,3 @@ If a property has only a getter method and has no setter method, it is considere
to modify the property value will cause an exception.
to modify the property value will cause an exception.
One can call
[
[hasProperty
]
],
[
[canGetProperty
]
] and/or
[
[canSetProperty
]
] to check the existence of a property.
One can call
[
[hasProperty
]
],
[
[canGetProperty
]
] and/or
[
[canSetProperty
]
] to check the existence of a property.
Besides the property feature, the Object class defines a static method
[
[create
]
] which provides a convenient
alternative way of creating a new object instance.
docs/api/db/ActiveRecord.md
View file @
d5d241e8
ActiveRecord implements the
[
Active Record design pattern
](
http://en.wikipedia.org/wiki/Active_record
)
.
ActiveRecord implements the
[
Active Record design pattern
](
http://en.wikipedia.org/wiki/Active_record
)
.
The idea is that ActiveRecord object is associated with a row in a database table
The idea is that
an
ActiveRecord object is associated with a row in a database table
so object properties are mapped to colums of the corresponding database row.
so object properties are mapped to colums of the corresponding database row.
For example, a
`Customer`
object is associated with a row in the
`tbl_customer`
For example, a
`Customer`
object is associated with a row in the
`tbl_customer`
table. Instead of writing raw SQL statements to access the data in the table,
table. Instead of writing raw SQL statements to access the data in the table,
...
@@ -62,7 +62,7 @@ There are two ActiveRecord methods for getting data:
...
@@ -62,7 +62,7 @@ There are two ActiveRecord methods for getting data:
-
[
[find()
]
]
-
[
[find()
]
]
-
[
[findBySql()
]
]
-
[
[findBySql()
]
]
They
all
return an
[
[ActiveQuery
]
] instance. Coupled with the various customization and query methods
They
both
return an
[
[ActiveQuery
]
] instance. Coupled with the various customization and query methods
provided by
[
[ActiveQuery
]
], ActiveRecord supports very flexible and powerful data retrieval approaches.
provided by
[
[ActiveQuery
]
], ActiveRecord supports very flexible and powerful data retrieval approaches.
The followings are some examples,
The followings are some examples,
...
@@ -158,7 +158,7 @@ $customer = Customer::find($id);
...
@@ -158,7 +158,7 @@ $customer = Customer::find($id);
$customer->delete();
$customer->delete();
// to increment the age of all customers by 1
// to increment the age of all customers by 1
Customer::updateAllCounters(array('age' =>
+
1));
Customer::updateAllCounters(array('age' => 1));
~~~
~~~
...
@@ -386,10 +386,10 @@ When getting an ActiveRecord instance through the [[find()]] method, we will hav
...
@@ -386,10 +386,10 @@ When getting an ActiveRecord instance through the [[find()]] method, we will hav
When calling
[
[save()
]
] to insert or update an ActiveRecord, we will have the following life cycles:
When calling
[
[save()
]
] to insert or update an ActiveRecord, we will have the following life cycles:
1.
[
[beforeValidate()
]
]: will trigger an
[
[EVENT_BEFORE_VALIDATE
]
] event
1.
[
[beforeValidate()
]
]: will trigger an
[
[EVENT_BEFORE_VALIDATE
]
] event
2.
[
[
beforeSave()
]
]: will trigger an
[
[EVENT_BEFORE_INSERT
]
] or
[
[EVENT_BEFORE_UP
DATE
]
] event
2.
[
[
afterValidate()
]
]: will trigger an
[
[EVENT_AFTER_VALI
DATE
]
] event
3.
perform the actual data insertion or updating
3.
[
[beforeSave()
]
]: will trigger an
[
[EVENT_BEFORE_INSERT
]
] or
[
[EVENT_BEFORE_UPDATE
]
] event
4.
[
[afterSave()
]
]: will trigger an
[
[EVENT_AFTER_INSERT
]
] or
[
[EVENT_AFTER_UPDATE
]
] event
4.
perform the actual data insertion or updating
5.
[
[after
Validate()
]
]: will trigger an
[
[EVENT_AFTER_VALI
DATE
]
] event
5.
[
[after
Save()
]
]: will trigger an
[
[EVENT_AFTER_INSERT
]
] or
[
[EVENT_AFTER_UP
DATE
]
] event
Finally when calling
[
[delete()
]
] to delete an ActiveRecord, we will have the following life cycles:
Finally when calling
[
[delete()
]
] to delete an ActiveRecord, we will have the following life cycles:
...
...
docs/model.md
View file @
d5d241e8
...
@@ -7,7 +7,7 @@ Attributes
...
@@ -7,7 +7,7 @@ Attributes
Attributes store the actual data represented by a model and can
Attributes store the actual data represented by a model and can
be accessed like object member variables. For example, a
`Post`
model
be accessed like object member variables. For example, a
`Post`
model
may contain a
`title`
attribute and a
`content`
attribute which may be
may contain a
`title`
attribute and a
`content`
attribute which may be
accessed as follows
,
accessed as follows
:
~~~
php
~~~
php
$post
->
title
=
'Hello, world'
;
$post
->
title
=
'Hello, world'
;
...
@@ -51,7 +51,7 @@ Scenarios
...
@@ -51,7 +51,7 @@ Scenarios
A model may be used in different scenarios. For example, a
`User`
model may be
A model may be used in different scenarios. For example, a
`User`
model may be
used to collect user login inputs, and it may also be used for user registration
used to collect user login inputs, and it may also be used for user registration
purpose. For this reason, each model has a property named
`scenario`
which stores
purpose. For this reason, each model has a property named
`scenario`
which stores
the name of the scenario that the model is currently being used. As we will explain
the name of the scenario that the model is currently being used
in
. As we will explain
in the next few sections, the concept of scenario is mainly used in validation and
in the next few sections, the concept of scenario is mainly used in validation and
massive attribute assignment.
massive attribute assignment.
...
...
framework/
util/ConsoleHelper
.php
→
framework/
console/View
.php
View file @
d5d241e8
This diff is collapsed.
Click to expand it.
framework/db/ActiveRecord.php
View file @
d5d241e8
...
@@ -602,13 +602,13 @@ class ActiveRecord extends Model
...
@@ -602,13 +602,13 @@ class ActiveRecord extends Model
*
*
* 1. call [[beforeValidate()]] when `$runValidation` is true. If validation
* 1. call [[beforeValidate()]] when `$runValidation` is true. If validation
* fails, it will skip the rest of the steps;
* fails, it will skip the rest of the steps;
* 2. call [[beforeSave()]]. If the method returns false, it will skip the
* 2. call [[afterValidate()]] when `$runValidation` is true.
* 3. call [[beforeSave()]]. If the method returns false, it will skip the
* rest of the steps;
* rest of the steps;
* 3. insert the record into database. If this fails, it will skip the rest of the steps;
* 4. insert the record into database. If this fails, it will skip the rest of the steps;
* 4. call [[afterSave()]];
* 5. call [[afterSave()]];
* 5. call [[afterValidate()]] when `$runValidation` is true.
*
*
* In the above step 1, 2,
4
and 5, events [[EVENT_BEFORE_VALIDATE]],
* In the above step 1, 2,
3
and 5, events [[EVENT_BEFORE_VALIDATE]],
* [[EVENT_BEFORE_INSERT]], [[EVENT_AFTER_INSERT]] and [[EVENT_AFTER_VALIDATE]]
* [[EVENT_BEFORE_INSERT]], [[EVENT_AFTER_INSERT]] and [[EVENT_AFTER_VALIDATE]]
* will be raised by the corresponding methods.
* will be raised by the corresponding methods.
*
*
...
@@ -673,13 +673,13 @@ class ActiveRecord extends Model
...
@@ -673,13 +673,13 @@ class ActiveRecord extends Model
*
*
* 1. call [[beforeValidate()]] when `$runValidation` is true. If validation
* 1. call [[beforeValidate()]] when `$runValidation` is true. If validation
* fails, it will skip the rest of the steps;
* fails, it will skip the rest of the steps;
* 2. call [[beforeSave()]]. If the method returns false, it will skip the
* 2. call [[afterValidate()]] when `$runValidation` is true.
* 3. call [[beforeSave()]]. If the method returns false, it will skip the
* rest of the steps;
* rest of the steps;
* 3. save the record into database. If this fails, it will skip the rest of the steps;
* 4. save the record into database. If this fails, it will skip the rest of the steps;
* 4. call [[afterSave()]];
* 5. call [[afterSave()]];
* 5. call [[afterValidate()]] when `$runValidation` is true.
*
*
* In the above step 1, 2,
4
and 5, events [[EVENT_BEFORE_VALIDATE]],
* In the above step 1, 2,
3
and 5, events [[EVENT_BEFORE_VALIDATE]],
* [[EVENT_BEFORE_UPDATE]], [[EVENT_AFTER_UPDATE]] and [[EVENT_AFTER_VALIDATE]]
* [[EVENT_BEFORE_UPDATE]], [[EVENT_AFTER_UPDATE]] and [[EVENT_AFTER_VALIDATE]]
* will be raised by the corresponding methods.
* will be raised by the corresponding methods.
*
*
...
...
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