Anyone? I've been hashing over this for hours now and the clue-fairy hasn't made an appearance yet. Ican't believe this is impossible to do with Cake so I must have something wrong somewhere.
class Fund extends AppModel { var $name = 'Fund'; var $useTable = 'funds'; var $belongsTo = array('FundType'); var $hasAndBelongsToMany = array( 'Discipline' => array( 'className' => 'Discipline', 'joinTable' => 'funds_disciplines', 'foreignKey' => 'discipline_id', 'associationForeignKey' => 'fund_id' ) ); } class AskFundType extends AppModel { var $name = 'AskFundType'; var $useTable = 'fund_types'; var $hasMany = 'Fund'; } class Discipline extends AppModel { var $name = 'Discipline'; var $hasAndBelongsToMany = array( 'AskFunder' => array( 'className' => 'AskFunder', 'joinTable' => 'ask_funders_disciplines', 'foreignKey' => 'ask_funder_id', 'associationForeignKey' => 'discipline_id' ), ); } class FundsController extends AppController { var $name = 'Funds'; var $paginate = array( 'limit' => 10, 'page' => 1, 'order'=>array('Fund.name' => 'ASC'), 'fields' => array( 'Fund.id', 'Fund.name', 'Fund.short_description' ) ); function listByDisciplineAndType() { ... $conditions = array( 'Fund.fund_type_id' => $fund_type_id, 'Discipline.id' => $discipline_id ); $this->set('funds', $this->paginate('Fund', $conditions)); } ... The really strange thing is, if i remove "'Discipline.id' => $discipline_id" from the $conditions, I get: Array ( [0] => Array ( [Fund] => Array ( [id] => 168 [name] => THE_FUND_NAME [short_description] => THE_FUND_DESCRIPTION ) [Discipline] => Array ( ) ) ... ) So, why is it that Cake refuses to select on disciplines but still adds the Discipline array (albeit empty) here? What the heck is going on? On Sat, Mar 8, 2008 at 2:10 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > (Cake1.2, using Bindable) > > Just when I thought I had this figured out... > > I have 3 models: > > Fund => belongsTo (FundType), HABTM(Discipline) > FundType => hasMany(Fund) > Discipline => HABTM(Fund) > > FundsController: > > function listByDisciplineAndType() > { > $discipline_slug = $this->params['discipline_slug']; > $fund_type_slug = $this->params['fund_type_slug']; > > $fields = array('Fund.name', [Fund.etc...]); > $criteria = array( > 'conditions' => array( > 'Discipline.slug' => $discipline_slug, > 'FundType.slug' => $fund_type_slug > ), > 'restrict' => array( > 'Discipline(name, slug)', > 'FundType(name)' > ) > ); > > $this->set('funders', $this->Fund->find('all', $criteria, $fields)); > } > > For some reason beyond my ken, Cake isn't selecting on Discipline > (I've also tried adding it to the $fields array). > > Can anyone point out out my error? > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---