【发布时间】:2011-12-19 04:31:07
【问题描述】:
我有 cmets 功能,我在 cmets 表中有“状态”字段 ..我想检查这个特定的字段值是否等于 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'));
}
}
【问题讨论】:
标签: cakephp controller cakephp-1.3