#5890: updateAll() shoudl return list of id's updated?
------------------------+---------------------------------------------------
    Reporter:  oh4real  |          Type:  Enhancement
      Status:  new      |      Priority:  Low        
   Milestone:  1.2.x.x  |     Component:  Model      
     Version:  RC2      |      Severity:  Minor      
    Keywords:           |   Php_version:  PHP 5      
Cake_version:           |  
------------------------+---------------------------------------------------
 Since updateAll() is a 'blind' function, it might be helpful to specify a
 parameter wherein it would return a list of IDs that were changed. In this
 way an updateAll with a restrictive condition like:
 {{{
 
$this->updateAll(array('Model.field2'=>1),array('Model.field1'=>$param,'NOT'=>array('Model.field2'=>0));
 }}}

 If it returned a list of IDs affected, then the user could use this in a
 conditional to execute specific code, like:

 {{{
 if($updated = $this->updateAll(... stuff from above ...) ) {
      foreach($updated as $update)
           {$this->sendEmail($update);}
      }
 }}}

 The simple boolean response is a bit unhelpful. Currently I have to run
 the two queries, like:
 {{{
 $update_conditions =
 array('Model.field1'=>$param,'NOT'=>array('Model.field2'=>0));
 if($updated = $this->find('list',array('conditions'=>$update_conditions))
      {
      $this->updateAll(array('Model.field2'=>1),$update_conditions);
      foreach($updated as $update) {
           $this->sendNotifyEmail($update);
      }
 }
 }}}
 Anyway, something like this might be nice to get this built-in instead of
 continuously recoding it.

 I haven't studied the updateAll()/save() aspect of API to know if it
 wouldn't be massively burdensome.

 Also, this would only be available on Model table, no hasOne/hasMany ones.

 Regards,
 oh4real

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5890>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to