@@ -76,8 +76,7 @@ There are two ActiveRecord methods for querying data from database:
-[[ActiveRecord::find()]]
-[[ActiveRecord::findBySql()]]
Both methods return an [[ActiveQuery]] instance, which extends [[Query]], and thus supports
the same set of flexible and powerful DB query methods. The following examples demonstrate some of the possibilities.
Both methods return an [[ActiveQuery]] instance, which extends [[Query]], and thus supports the same set of flexible and powerful DB query methods. The following examples demonstrate some of the possibilities.
```php
// to retrieve all *active* customers and order them by their ID:
...
...
@@ -119,8 +118,7 @@ Accessing Column Data
---------------------
ActiveRecord maps each column of the corresponding database table row to an attribute in the ActiveRecord
object. The attribute behaves like any regular object public property. The attribute's name will be the same as the corresponding column
name, and is case-sensitive.
object. The attribute behaves like any regular object public property. The attribute's name will be the same as the corresponding column name, and is case-sensitive.
To read the value of a column, you can use the following syntax:
...
...
@@ -151,9 +149,7 @@ ActiveRecord provides the following methods to insert, update and delete data in
Note that [[ActiveRecord::updateAll()|updateAll()]], [[ActiveRecord::updateAllCounters()|updateAllCounters()]]
and [[ActiveRecord::deleteAll()|deleteAll()]] are static methods that apply to the whole database
table. The other methods only apply to the row associated with the ActiveRecord object through which the method is being called.
Note that [[ActiveRecord::updateAll()|updateAll()]], [[ActiveRecord::updateAllCounters()|updateAllCounters()]] and [[ActiveRecord::deleteAll()|deleteAll()]] are static methods that apply to the whole database table. The other methods only apply to the row associated with the ActiveRecord object through which the method is being called.
```php
// to insert a new customer record
...
...
@@ -477,7 +473,7 @@ of the corresponding JOIN query. For example,
```php
// SELECT tbl_user.* FROM tbl_user LEFT JOIN tbl_item ON tbl_item.owner_id=tbl_user.id AND category_id=1
// SELECT * FROM tbl_item WHERE owner_id IN (...) AND category_id=1
$users=User::model()->joinWith('books')->all();
$users=User::find()->joinWith('books')->all();
```
Note that if you use eager loading via [[ActiveQuery::with()]] or lazy loading, the on-condition will be put
...
...
@@ -485,7 +481,7 @@ in the WHERE part of the corresponding SQL statement, because there is no JOIN q
```php
// SELECT * FROM tbl_user WHERE id=10
$user=User::model(10);
$user=User::find(10);
// SELECT * FROM tbl_item WHERE owner_id=10 AND category_id=1
$books=$user->books;
```
...
...
@@ -552,7 +548,7 @@ Custom scopes
When [[find()]] or [[findBySql()]] Active Record method is being called without parameters it returns an [[ActiveQuery]]
instance. This object holds all the parameters and conditions for a future query and also allows you to customize these
using a set of methods that are called scopes. By deafault there is a good set of such methods some of which we've
using a set of methods that are called scopes. By default there is a good set of such methods some of which we've
already used above: `where`, `orderBy`, `limit` etc.
In many cases it is convenient to wrap extra conditions into custom scope methods. In order to do so you need two things.
...
...
@@ -561,7 +557,7 @@ First is creating a custom query class for your model. For example, a `Comment`