Yii Framework Forum: DELETEALL with criteria and with params - Yii Framework Forum

Jump to content

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

DELETEALL with criteria and with params Rate Topic: -----

#1 User is offline   MagnusSolution 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 13-August 12

Posted 03 January 2018 - 07:48 AM

$criteria = new CDbCriteria(array(
                'condition' => $this->filter,
                'params'    => $this->paramsFilter,
                 'with'      => $this->relationFilter
            ));
           
            try {
                $this->success = $this->abstractModel->deleteAll($criteria);
            } catch (Exception $e) {
                $this->success = false;
                $errors        = $this->getErrorMySql($e);
            }


this code not work, because not use with params, like findAll.

what is the best form to make this DELETE work?
www.magnusbilling.com
0

#2 User is offline   alrazi 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,546
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 03 January 2018 - 08:31 AM

I can't help you much by look at the snippet above but if you trying to delete records based on a condition in a second table try a join

$criteria = new CDbCriteria(array(
    'condition' => $this->filter,
    'params'    => $this->paramsFilter,
    'with'      => $this->relationFilter // you could try doing and join here
));


http://www.yiiframew...ria#join-detail
1

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