user1047813
user1047813

Reputation: 67

Cakephp return only one record using findby method

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

Answers (1)

Doug Owings
Doug Owings

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

Related Questions