Cakephp MySql 使用 WHERE 查询
Cakephp MySql Query with WHERE
我有功函数:
public function index()
{
$this->set('tables', $this->Table->find('all'));
}
但是如何只显示 WHERE owner = logged user 列?
您想做这样的事情,其中 $this->Session->read()
returns 当前经过身份验证的用户:-
$this->Table->find(
'all',
array(
'conditions' => array('Table.user_id' => $this->Session->read("Auth.User.id"))
)
);
我有功函数:
public function index()
{
$this->set('tables', $this->Table->find('all'));
}
但是如何只显示 WHERE owner = logged user 列?
您想做这样的事情,其中 $this->Session->read()
returns 当前经过身份验证的用户:-
$this->Table->find(
'all',
array(
'conditions' => array('Table.user_id' => $this->Session->read("Auth.User.id"))
)
);