Reputation: 67
Is there a way we can return only one field using findby method in Cakephp? so far I've got this
$user = $this->User->findbyUsername($username, array('User.id'));
But it seems to return all related results....
Upvotes: 0
Views: 519
Reputation: 4448
Try
$this->User->recursive = -1;
// If you are using the Containable behavior:
$this->User->contain();
$user = $this->User->findByUsername($username, array('fields' => 'User.id'));
Upvotes: 2