p30tec
(Sellthemeiran)
1
Hello
I need to use scope for updateAll , but in guide I see
So I cannot use it in updateAll ;
Because scope is the best option for me (In this case) to DRY(Don’t Repeat Yourself) , I have to use scope
I think for this problem and find solution
I do this to
$criteria = Post::model()->Scope1()->Scope2()->Scope3()->Scope4()->getDbCriteria();
Post::model()->updateAll(array('visit' =>new CDbExpression('visit+1')),$criteria);
Because in UPDATE query Yii dont define t
and main table alias , I have this error
How can I solve problem ??
Don’t let the DRY principle restrict you - if you need to write a criteria then do it.
Also, take a look here - http://www.yiiframework.com/doc/api/1.1/CActiveRecord#updateCounters-detail
p30tec
(Sellthemeiran)
3
Beecause in future I will change Scopes and I use these Scopes repetitively , If I want write a new criteria in future I have big issue
p30tec
(Sellthemeiran)
4
Thanks for http://www.yiiframework.com/doc/api/1.1/CActiveRecord#updateCounters-detail , it’s better than updateAll
but I have suitable criteria , This is good trick
$criteria = Post::model()->Scope1()->Scope2()->Scope3()->Scope4()->getDbCriteria();
Post::model()->updateAll(array('visit' =>new CDbExpression('visit+1')),$criteria);
the problem is t
alias , because in UPDATE query yii dont define alias
le_top
(Ext Yiiframework Com)
6