Anugrah
Anugrah

Reputation: 152

cakephp compare array with database fields

I'm developing an app in cakePHP. I'm supposed to take an array $data, which contains username and password (non-hashed), and compare it to all rows in table Customers where if it matches any row I'll send a message back saying user found. This is the code I've written:

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

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

Now I know that data is being set correctly, I know the problem is with the comparing parameters 'data.firstname' etc. What should be the correct syntax?

Upvotes: 1

Views: 753

Answers (1)

timstermatic
timstermatic

Reputation: 1740

Try:

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

Upvotes: 1

Related Questions