views:

68

answers:

3

hii..I want to edit single row.i used $this->data = $this->BuildingProperty->read(null,$id);

but it didnt fetch the values of this id.

so what can i do. Give me any suggestion.

A: 

Why did you pass null as the first parameter? It should be a string on array of fields that you want to retrieve.

Anyway, try this instead:

$this->BuildingProperty->id = $id;
$this->data = $this->BuildingProperty->read();
Gian Basagre
It's entirely appropriate to use `read()` like that. Passing `null` just means "all fields". http://book.cakephp.org/view/1029/read
deceze
thanks, but this one also not working.
Msofts
A: 

The syntax which you are using is correct. First check if the $id is integer. (echo $id). Then if so, check your database if it has such record in building_properties table check if this ID exist. Finally check if the variable $this->data is populated with the proper values.

All those checks return you proper values then the problem is not in Model->read() function.

Another hint, try to clear the cache /app/tmp/cache/modules and /app/tmp/cache/persistent

Nik
A: 

Are you calling the method from a controller that knows about BuildingProperty? i.e. BuildingPropertiesController. If not, have you included a

var $uses = array('BuildingProperty');

statement in the class definition or explicitly loaded the model with, for example,

loadModel('BuildingProperty')

Your syntax is correct and the only other explanation if there is no warning or error message is that the returned array is empty, i.e. the record does not exist.

Check that you have debug turned on:

Configure::write('debug', 1); // or higher.A 2 will output SQL queries as well

then try

debug($this->BuildingProperty->read(null,$id));

You should at least get some output telling you the line of the debug call.

Leo