Reputation: 21
In my PartsController I have the following code:
$serialNrs = $this->Part->find('list',
array(
'conditions'=>array(
'Part.status_id' => 3
),
'fields'=> array('serial_nr_id' )
//'fields'=> array('serialNr.name')
));
The according select field shows a list of id's instead of values.
When I use 'fields'=> array('serialNr.name')
I get an error:
SELECT Part
.serial_nr_id
, SerialNr
.name
FROM part145
.parts
AS Part
WHERE Part
.status_id
= 3
What do I need to do to show a list of values?
Upvotes: 0
Views: 576
Reputation: 464
You should use the Model name instead of the actual table name in database, thus
$serialNrs = $this->Part->find('list',
array(
'conditions'=>array(
'Part.status_id' => 3
),
'fields'=> array('Part.name' )
));
According to the above code, you have a model named "Part" where it points to a database table where there are at least a "status_id" column and a "name" column.
Upvotes: 1