Yii Framework Forum: Cdbcriteria: Specify Which Operations Are Applicable - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Cdbcriteria: Specify Which Operations Are Applicable Rate Topic: -----

#1 User is offline   jreznik 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 05-September 13

Posted 05 November 2013 - 04:00 PM

This is extending off the idea of having update*/delete* AR methods respect scopes. Currently, only select respects the scopes while there is no way to enable them on update/delete.

There was a PR for this issue a year ago which was not accepted: https://github.com/y...t/yii/pull/1660
Main reasons was this is against the original design and it is not backwards compatible. Issues with this (even if it was BC) was that defaultScope would interfere with proper selecting if this was meant for updates/deletes, or vice versa.

This CAN be accomplished in a backwards compatible manner: if CDbCriteria had an 'operations' property where we could specify which operations the scope applied to:
public function defaultScope()
{
    return array(
        'condition'=>'locked=0',
        'operations'=>array('update','delete'),
    );
}


This would apply the scope to only the update and delete DB operations. Omitting this parameter would result in default behavior of only applying it to select.

Simple, elegant, and extremely useful!
0

#2 User is offline   Shahcheraghean 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 478
  • Joined: 12-December 12
  • Location:Mashhad, IRAN

Posted 06 November 2013 - 01:07 AM

So marvelous.
May I ask you to describe your mean by an example?
www.shgn.ir
www.shgn.ir/yii-framework/
yii2.swsco.ir
In a world without any fences or walls,Who needs Gates or Windows!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users