JaquelineBrandao / yii

Automatically exported from code.google.com/p/yii
0 stars 0 forks source link

Yii default scope disabling #1001

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
it is no ability to temporarily disable defaultScope applying

What is the expected output? What do you see instead?
it should be ability to temporarily disable defaultScope applying, like a
useDefaultScope($use = false);

What version of the product are you using? On what operating system?
Yii 1.1.1

Original issue reported on code.google.com by iakreve...@gmail.com on 11 Mar 2010 at 4:09

GoogleCodeExporter commented 9 years ago
Set for next release.

Original comment by qiang.xue on 13 Mar 2010 at 2:18

GoogleCodeExporter commented 9 years ago
Planning to add resetScope() that will reset any scopes defined so far 
including 
default one. Syntax will be:

$posts = Post::model()->resetScope()->findAll();

Original comment by alexander.makarow on 17 Mar 2010 at 5:50

GoogleCodeExporter commented 9 years ago
ok, if resetScope() (in CActiveRecord.php) looks like:

public function resetScope(){
   $this->_c=new CDbCriteria();
   return $this;
}

or (in any model):

public function resetScope(){
 if(null!==($criteria=$this->getDbCriteria(false))){
   foreach(get_class_vars('CDbCriteria') as $k=>$v)
     $criteria->$k=$v;   
 }
 return $this;
}

how in this case I can restore defaultScope()?

Original comment by denis.gu...@gmail.com on 31 Mar 2010 at 8:20

GoogleCodeExporter commented 9 years ago

Original comment by alexander.makarow on 3 Apr 2010 at 7:30

GoogleCodeExporter commented 9 years ago
Why do you need to restore defaultScope while resetting all other scopes?

Original comment by alexander.makarow on 7 Apr 2010 at 8:43

GoogleCodeExporter commented 9 years ago
i think method name should be resetDefaultScope instead of resetScope, because 
of if
we dont call some defined scope it is obviously that it will not be used.

Original comment by iakreve...@gmail.com on 8 Apr 2010 at 2:14

GoogleCodeExporter commented 9 years ago
It will reset all scopes, not only default one.

Original comment by alexander.makarow on 8 Apr 2010 at 2:16

GoogleCodeExporter commented 9 years ago
is there real need to call model()::recent()->resetScope()->findAll() instead of
model()::findAll() ?

Original comment by iakreve...@gmail.com on 8 Apr 2010 at 3:05

GoogleCodeExporter commented 9 years ago
If you need to reset scope — yes. Alternative is not to define default scope 
at all.

Original comment by alexander.makarow on 8 Apr 2010 at 3:08

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2064.

Original comment by alexander.makarow on 20 Apr 2010 at 10:22

GoogleCodeExporter commented 9 years ago
How about allowing the CUniqueValidator to work outside the defaultScope as 
well with a simple 'option' when desired?

Original comment by ptheo...@gmail.com on 1 Oct 2011 at 3:25