Take a look at the model attribute for definition of the primary key, when a database is not following CakePHP conventions. See this: http://book.cakephp.org/view/437/primaryKey
That should help you a lot! :) Enjoy, John On Feb 4, 4:17 pm, doze <[email protected]> wrote: > Hmm.. I think I wasn't able to describe my problem fully.. But anyhow, > I resolved it by querying the related 'Kaannokset' records manually > for each 'Tekstit' in the controller, like so: > > function index() { > $this->Tuotteet->recursive = 1; > $tuotteetArray = $this->paginate(); > foreach ($tuotteetArray as &$tuotteet) { > $this->Tuotteet->Tekstit->Kaannokset->contain(); > $kaannokset = $this->Tuotteet->Tekstit->Kaannokset->find('all', > array( > > 'conditions' => array('Kaannokset.teksti_id' => > $tuotteet['Tekstit']['id']) > )); > $tuotteet['Tekstit']['Kaannokset'] = $kaannokset; > } > $this->set('tuotteet', $tuotteetArray); > } > > The main issues I have is that my customer has already defined the > database and the columns or table names cannot be changed. He is > already using other columns than 'id' as the primary keys and doing > the relations between tables sucks in cake when not following the > conventions. > > What I would need is to be able to define localKey for the model > relations so that cake would use it as the 'id' field. > > I saw a pach for this (http://groups.google.com.pk/group/tickets- > cakephp/browse_thread/thread/65488e266621ad0c) > > But that patch was closed with note to use: 'foreignKey' => false and > 'conditions' and that's what I have tried to use, but it gives me the > sql errors as cake won't do the necessary JOINS according to > conditions. [snip] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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
