Okay, So I am working on my second cake project, this one has a much more complicated data structure.
I have one table called "schools" which lists colleges, I have another
called "Majors" which lists majors, and finally I have a join called
school_majors.
I ahve set up a HABTM (majors) on the school model and HABTM (schools)
on the major model using the school_majors table as the crosswalk,
however I also need some data from the school_majors join table in my
school view (it is more than just a join table). So I have created a
hasMany(schoolMajor) connection on the school table as well.
When I run queries, I get a mysql error telling me that there is no
SchoolMajor table. essentially, the model is not using the hasMany
connection and the SchoolMajor table is not in the query.
However, if I create a hasOne relation ship to the schoolMajor table,
the query works, except the number of results returned for each school
is equal to the number of records the school has in the schoolMajor
table.
In any event, here are my connections:
SCHOOL MODEL:
var $hasMany = array(
'SchoolMajor' =>
array('className' => 'SchoolMajor',
'foreignKey' => 'school_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'dependent' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
var $hasAndBelongsToMany = array(
'Major' =>
array('className' => 'Major',
'joinTable' => 'school_majors',
'foreignKey' => 'school_id',
'associationForeignKey' =>
'cipcode',
'conditions' => 'Major.cipcode
!="-----"',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'unique' => 'true',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),
'IsReligion' =>
array('className' => 'IsReligion',
'joinTable' =>
'school_admissions',
'foreignKey' => 'school_id',
'associationForeignKey' =>
'relaffil',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'unique' => 'true',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
++++++++++++++++++++++++++++++++++++++++++++++++
SchoolMajor MODEL:
var $hasMany = array(
'SchoolMajor' =>
array('className' => 'SchoolMajor',
'foreignKey' => 'school_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'dependent' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
var $hasAndBelongsToMany = array(
'Major' =>
array('className' => 'Major',
'joinTable' => 'school_majors',
'foreignKey' => 'school_id',
'associationForeignKey' =>
'cipcode',
'conditions' => 'Major.cipcode
!="-----"',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'unique' => 'true',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),
'IsReligion' =>
array('className' => 'IsReligion',
'joinTable' =>
'school_admissions',
'foreignKey' => 'school_id',
'associationForeignKey' =>
'relaffil',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'unique' => 'true',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
)
);
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Major Model:
var $hasAndBelongsToMany = array(
'School' =>
array('className' => 'School',
'joinTable' => 'school_majors',
'foreignKey' => 'cipcode',
'associationForeignKey' =>
'school_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'unique' => 'true',
'finderQuery' => '',
'deleteQuery' => '',
'insertQuery' => ''
),
);
Major MODEl
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
