In my project I can't use the default 'id' name for primary key
fields, I have to use 'no'.  I have to change a cake I already baked
from using 'no' to 'id' everywhere.  I hadn't customized it much and I
could easily change the database and everywhere I could see in the
views and models, and most pages work perfectly as before, except this
one where the join is a HABTM.

It is a dictionary app where a term can have many contexts and a
context many terms.  The query that is failing when I visit
/contexts/view/5 is still looking for an '_id' field on the join, like
this:

Query: SELECT `Term`.`no`, `Term`.`term`, `Term`.`term_nice`,
`Term`.`display`, `Term`.`import_date`, `ContextsTerm`.`context_no`,
`ContextsTerm`.`term_no` FROM `terms` AS `Term` JOIN `contexts_terms`
AS `ContextsTerm` ON (`ContextsTerm`.`context_no` IN (5) AND
`ContextsTerm`.`term_id` = `Term`.`no`)

In the view I'm not even trying to view the list of terms, I removed
that section from the view that it baked, so I wish it weren't trying
to do that query, but it's just a warning not an error, but that query
crops up and breaks on another page as well where I do need it and I
don't know where to look..  Perplexed, I am new to cake, thanks..

term.php:
class Term extends AppModel {
    var $name = 'Term';
        var $displayField = 'term_nice';
        var $primaryKey = 'no';

        var $hasAndBelongsToMany = array('Context' =>
                        array('className'    => 'Context',
                                         'joinTable' => 'contexts_terms',
                                         'conditions'   => '',
                                         'order'        => '',
                                         'foreignKey'   => 'term_no'
           )
        );
}

context.php:
class Context extends AppModel {
        var $name = 'Context';
                var $displayField = 'name';
                var $primaryKey = 'no';

                var $hasAndBelongsToMany = array('Term' =>
                array('className'    => 'Term',
                                         'joinTable' => 'contexts_terms',
                     'conditions'   => '',
                     'order'        => '',
                     'foreignKey'   => 'context_no'
                )
        );
    }


// I have modeled this so I can get easy pagination on another page
which is also broken on that join
class ContextsTerm extends AppModel {
    var $belongsTo = array('Context','Term');
        var $primaryKey = 'context_no';
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to