开发者

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

开发者 https://www.devze.com 2023-04-03 13:53 出处:网络
What is the difference between these 2 commands in Cakephp? $this->Model->findbyId(7); $this->Model->read(null, 7);

What is the difference between these 2 commands in Cakephp?

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

I am 开发者_C百科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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消