Msofts
Msofts

Reputation: 87

read function problem (not read all fields) in cakephp

i want to edit row. view file contains dropwons with Ajax. i used $this->data = $this->CourseBuilding->read(null, $id); but it cant read all fields of that id.

Can U help me.

Upvotes: 0

Views: 930

Answers (3)

Amar
Amar

Reputation: 21

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

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

Upvotes: 0

Mehul Panchal
Mehul Panchal

Reputation: 1

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

Upvotes: -1

alexborbely
alexborbely

Reputation: 183

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);

Upvotes: 2

Related Questions