>
> Hi there,
>
> while developing some sort of app, which needs often to update an
> existing databse entry (integer), e.g. "every time guy A enters my
> site, guy A s counter gets +1"
>
> Doing this by native SQL Code is very simple "UPDATE entry SET entry =
> + 1" or "entry = entry+1", doing this in Cake seems nearly impossible
> for me. Because nothing i did work.
>
> Passing '+1' into the data array, or 'entry + 1' did not work, also
> updateAll did not worked with '+1'
>
> Any ideas instead of using model->query() ?
AppController::beforeFilter():
$this->Auth->autoRedirect = false;
UsersController:
public function login()
{
if (!empty($this->data) && $user = $this->Auth->user())
{
$new_entry = ++$user['User']['entry'];
$this->User->create($user);
$this->User->saveField('entry', $new_entry);
/* and update session value
*/
$this->Session->write('Auth.User.entry', $new_entry);
$this->redirect($this->Auth->loginRedirect);
}
}
--~--~---------~--~----~------------~-------~--~----~
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+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment