-2

我想知道如何创建一个函数,当单击记录的禁用按钮时,它将活动列的特定值更改为 0。它应该位于 ['Album']['active'] 下默认情况下是1。我试过了

if ($id) { $this ->data[$id]['Album']['active'] = 0; 
     $this->Album->save($this->data); 

谢谢

4

1 回答 1

0

试试这个功能:

function active($id=null)
{

       $this->Album->id = $id;
        $this->data = $this->Album->read();
        if($this->data['Album']['active']==0)
        {
            $this->data['Album']['active'] = 1;
        }
        else            {
            $this->data['Album']['active'] = 0;
        }
        if($this->Album->save($this->data['Album']))
        {
            $this->redirect('/Controller/action');
        }

}   
于 2012-08-27T12:14:30.670 回答