0
我有評論功能,我有評論表 ..中的「狀態」字段..如果它等於0 或不在控制器中,我想檢查此特定字段值。有人請幫助我改正這個代碼如何檢查控制器中的特定字段值
function admin_publish ($id = null){
if (!$id) {
// set flash message
$this->Session->setFlash('Invalid id for Location','default',
array('class' => 'flash_bad'));
// redirect
$this->redirect(array('action'=>'admin_index'));
}else{
// if comment status field 0
if($comments['Comment']['status']== null){
// change status from 0 to 1
$this->Comment->saveField('status',1);
// set flash message
$this->Session->setFlash('The Comment was successfully
Published.');
} else {
$this->Comment->saveField('status', 0);
// set flash message
$this->Session->setFlash('The Comment could not be NotPublished.');
}
// redirect
$this->redirect(array('action'=>'admin_index'));
}
}
蘇德赫感謝幫助...它是作品 – user1080247