On Dec 18, 8:12 am, gearvOsh <mileswjohn...@gmail.com> wrote:
> I still have yet to find a straight forward way to do this, so ill
> simply do something like this:
>
> function update($user_id, $fields) {
>         if (is_array($fields)) {
>                 App::import('Sanitize');
>                 Sanitize::clean($fields);
>
>                 $cleanFields = array();
>                 foreach ($fields as $field => $value) {
>                         $cleanFields[] = "User.". $field ." = '". $value ."'";
>                 }
>
>                 $sql = "UPDATE users AS User SET ". implode(', ', 
> $cleanFields) ."
> WHERE User.id = ". Sanitize::escape($user_id) ." LIMIT 1";
>                 return $this->query($sql);
>         }
>
>         return NULL;
>
> }

What the hell is that :D?

FIND the reason your save is failing, that's even worse that putting
model logic in a controller. If nothing else debug the save method and
see where it returns false. It's always amusing to see the hoops
people jump through rather than debug/investigate the core - it is
afer all 'just' PHP.

AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to