cakephp将数组与数据库字段进行比较

时间:2013-09-16 09:57:30

标签: php arrays cakephp

我正在开发cakePHP中的应用程序。我应该采用数组$ data,其中包含用户名和密码(非散列),并将其与表Customers中的所有行进行比较,如果它匹配任何行,我将发回消息说用户找到。这是我写的代码:

$data = $this->request->input('json_decode');
$data = $this->Customer->findByUsernameAndPassword('data.firstname','data.lastname');

if ($data) { ...message...}

现在我知道数据设置正确,我知道问题在于比较参数'data.firstname'等。正确的语法应该是什么?

1 个答案:

答案 0 :(得分:1)

尝试:

$data = $this->Customer->findByUsernameAndPassword($data['username'],$data['password']);