Hi,
I am fairly new to CakePHP, being handed a project that now needs some work. I want to update all notifications as read. I found code that updates one notification, which works fine:
public function markread($notificationId) {
try {
$notificationModel = ClassRegistry::init(array('class' => 'UserNotification'));
$notificationModel->updateAll(array(
'UserNotification.is_read' => self::NOTIFICATION_READ,
'UserNotification.updated_at' => "'" . date('Y-m-d H:i:s') . "'",
), array(
'UserNotification.id' => $notificationId
));
} catch(Exception $e) {
throw $e;
}
}
I now want an option to update ALL as read for a user id… I am using this but it is not updating anything. What have I missed?
public function markAllNotificationsAsRead($userId) {
try {
$notificationModel = ClassRegistry::init(array('class' => 'UserNotification'));
$notificationModel->updateAll(
array('UserNotification.is_read' => self::NOTIFICATION_READ,'UserNotification.updated_at' => "'" . date('Y-m-d H:i:s') . "'"),
array('UserNotification.user_id' => $userId)
);
} catch(Exception $e) {
throw $e;
}
}