开发者

read function problem (not read all fields) in cakephp

开发者 https://www.devze.com 2023-01-04 13:22 出处:网络
i want to edit row. view file contains dropwons with Ajax. i used $this->data = $this->CourseBuilding->read(nu开发者_Go百科ll, $id); but it cant read all fields of that id.

i want to edit row. view file contains dropwons with Ajax. i used $this->data = $this->CourseBuilding->read(nu开发者_Go百科ll, $id); but it cant read all fields of that id.

Can U help me.


From http://api.cakephp.org/class/model#method-Modelread - you can pass all the fields you want as a parameter to the read method like this:

$this->CourseBuilding->read(array('field1', 'field2', ...), $id);

or you can use this instead:

$this->CourseBuilding->findById($id);


$this->CourseBuilding->read('*',$id);

By using * as the first argument of the read method will return all the fields of that model.


pass id to url name id

then when retrive data use $id=$this->params['id'];

and

$this->Your model name->id = $id;

$this->data = $this->Your model name->read();

U will receive your data

Thanks Mehul

0

精彩评论

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