Difference between #21 and #22 of
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.

Revision #22 has been created by Gerhard Liebenberg on Apr 27, 2013, 10:59:39 PM with the memo:

added link to defaultScope wiki
« previous (#21)

Changes

Title unchanged

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.

Category unchanged

How-tos

Yii version unchanged

Tags unchanged

reuse filtering criteria; parameterized named scope in dataprovider

Content changed

[...]
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
3 1
3 followers
Viewed: 23 457 times
Version: 1.1
Category: How-tos
Written by: Gerhard Liebenberg
Last updated by: Gerhard Liebenberg
Created on: Jan 7, 2013
Last updated: 10 years ago
Update Article

Revisions

View all history