Parameterized Named Scope. Re-use the same set of filtering criteria in various models and controllers. Also re-use the same Parameterized Named Scope in all find() functions and in dataprovider.

Comparing #21 with #22

Revision #22 was created by Gerhard Liebenberg Gerhard Liebenberg on Apr 27, 2013, 10:59:39 PM.

added link to defaultScope wiki

Content

[...]
Use method-1 whenever you directly load records e.g. actionUpdate and actionDelete - via loadModel($id).

Use method-2 when you need a dataprovider e.g. CGridView & CListView.

### Warning:
This Row-Level-Access-Control I used is just an example to explain pns. However, Row-Level-Access-Control should probably involve defaultScope(), because pns is currently (Yii 1.1.12) not enforced on related tables in relational queries.
Here is a wiki on [defaultScope](http://www.yiiframework.com/wiki/486/defaultscope/ "defaultScope") doing the same kind of thing as shown in this wiki.  Thanx