I have a problem when I try to select distinct fields in an associated
model with find. The models "Address" und "Expertise" have a HABTM
relation.
I have the following code in my controller. (There is no table named
mitglieder).
<?php
class MitgliederController extends AppController {
var $name = 'Mitglieder';
var $uses = array('Address','Expertise');
function de_index() {
$fachgebiete = $this->Expertise->find('list');
$this->set('fachgebiete',$fachgebiete);
$berufe = $this->Presentation->query('SELECT DISTINCT
beruf FROM `addresses` WHERE `mitglied` = "J" ORDER BY beruf ASC');
$this->set('berufe',$berufe);
$mitglieder = $this->Address->find('all',array
('fields'=>array
('Address.name','Expertise.fachgebiet'),'conditions'=>'`Address.mitglied`
= "J"','order'=>'`created` ASC','recursive'=>'1'));
$this->set('mitglieder',$mitglieder);
}
}
?>
I get the following error for the last find: "SQL Error: 1054: Unknown
column 'Expertise.fachgebiet' in 'field list'"
Query: SELECT `Address`.`name`, `Expertise`.`fachgebiet` FROM
`addresses` AS `Address` WHERE `Address`.`mitglied` = "J" ORDER BY
`created` ASC
What am I missing? I found examples like this in the web for cakephp.
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---