Dennis
Dennis

Reputation: 2964

What is the difference between $this->Cake->findById(7); and read(

What is the difference between these 2 commands in Cakephp?

$this->Model->findbyId(7);
$this->Model->read(null, 7);

I am trying to improve my Cakephp code and wonder what the best way is to request individual items from the database, e.g. for /view/$id.

Should I use findbyId or read()? I have even seen people use find('first') with an id=$id condition.

Upvotes: 1

Views: 540

Answers (1)

Rob Wilkerson
Rob Wilkerson

Reputation: 41256

read() sets the model data. There's some good info at http://nuts-and-bolts-of-cakephp.com/2008/06/13/read-vs-find/.

Upvotes: 1

Related Questions