Cakephp不能更新shell文件中的数据


Cakephp can't update data in shell file

下面的shell脚本应该更新通知。一旦发送了电子邮件通知,但它不工作,则发送电子邮件数据库单元格。我已经尝试了保存方法和saveField方法,但它们不起作用。我从控制台调用shell,没有错误,$id和$email显示在屏幕上,按照脚本的最后2行。我无法调试,因为没有错误。请帮助。

下面是我的shell脚本的一部分:
<?php
App::uses('CakeEmail', 'Network/Email');
class EmailnotificationShell extends AppShell {
public $uses = array('User', 'Notification');
public function fsnotify() {
    $notifications = $this->Notification->find('all', array(
    'recursive' => 1,
    'conditions' => array('Notification.viewed' => '0', 'Notification.emailed' => '0', 'User.emailauth' => '1'),
    'group' => array('Notification.user_id')
    ));
    foreach ($notifications as $notification){
    $email = $notification['User']['email'];
    $id = $notification['Notification']['id'];
      $this->Notification->id = $id;
      // $this->Notification->saveField('emailed', 1, array('validate' => false, 'callbacks' => false));
      $data = array('Notification.emailed' => 1);
      $this->Notification->save($data);
      $this->Notification->clear();
     // below lines for testing in console
      $this->out($id);
      $this->out($email);
    }
}

您不应该在保存数据数组中的列名前面加上别名。所以下面是:-

$data = array('Notification.emailed' => 1);
$this->Notification->save($data);

应该是:-> 果仍然没有保存,那么尝试检查任何验证错误:-

debug($this->Notification->invalidFields());

没有明显的错误并不意味着没有办法调试你的代码!: -)