My suspicion that auto-generated models are being used has been
confirmed. Here are snippets of Debug::dump($AdsRundate). First
under 1.2.0.7296 RC2 and next under 1.2.2.8120
1.2.0.7296 RC2
AdsRundate
AdsRundate::$name = "AdsRundate"
AdsRundate::$validate = array
AdsRundate::$belongsTo = array
AdsRundate::$useDbConfig = "default"
AdsRundate::$useTable = "ads_rundates"
...
1.2.2.8120
AppModel
AppModel::$useDbConfig = "default"
AppModel::$useTable = "ads_rundates"
AppModel::$displayField = "id"
AppModel::$id = false
AppModel::$data = array
AppModel::$table = "ads_rundates"
AppModel::$primaryKey = "id"
Here's a log dump from a query using the same method with both cores:
1.2.0.7296 RC2
2009-05-08 19:49:50 Error: Array
(
[0] => Array
(
[AdsRundate] => Array
(
[id] => 6437
[ad_id] => 1360
[rundate_id] => 78
[free_week] => 0
[ad_bill_id] => 44
)
[Rundate] => Array
(
[id] => 78
[run_date] => 2009-05-13
[Ad] => Array
(
)
)
)
[1] => Array
(
[AdsRundate] => Array
(
[id] => 6438
[ad_id] => 1360
[rundate_id] => 79
[free_week] => 0
[ad_bill_id] => 44
)
[Rundate] => Array
(
[id] => 79
[run_date] => 2009-05-20
[Ad] => Array
(
)
)
)
[2] => Array
(
[AdsRundate] => Array
(
[id] => 6439
[ad_id] => 1360
[rundate_id] => 80
[free_week] => 0
[ad_bill_id] => 44
)
[Rundate] => Array
(
[id] => 80
[run_date] => 2009-05-27
[Ad] => Array
(
)
)
)
)
1.2.2.8120
2009-05-09 13:58:25 Error: Array
(
[0] => Array
(
[AdsRundate] => Array
(
[id] => 6437
[ad_id] => 1360
[rundate_id] => 78
[free_week] => 0
[ad_bill_id] => 44
)
)
[1] => Array
(
[AdsRundate] => Array
(
[id] => 6438
[ad_id] => 1360
[rundate_id] => 79
[free_week] => 0
[ad_bill_id] => 44
)
)
[2] => Array
(
[AdsRundate] => Array
(
[id] => 6439
[ad_id] => 1360
[rundate_id] => 80
[free_week] => 0
[ad_bill_id] => 44
)
)
)
I hope this data is helpful in solving this mystery. I could start
digging into the core code to see what tests are failing to make it
auto generate this model, but I'd rather not open that can of worms if
I don't need to.
Thanks again.
Jeff
On May 8, 7:37 pm, J3ffy <[email protected]> wrote:
> Hello, cake community. I'm suffering through one of those frustrating
> problems where things worked fine until the core was upgraded.
>
> The app I'm currently working on uses many HABTM relationships. Some
> of the join tables for these relationships have additional fields, so
> I've created models for the join tables. In doing so, I added the
> 'with' key to the respective joined models. I also added belongsTo
> associations in the join table models to each of the tables they join:
>
> class Ad extends AppModel {
> var $name = 'Ad';
> var $hasAndBelongsToMany = array(
> 'Rundate' =>
> array(
> 'with' => 'AdsRundate',
> 'className' => 'Rundate',
> 'joinTable' => 'ads_rundates',
> 'foreignKey' => 'ad_id',
> 'associationForeignKey' => 'rundate_id',
> 'conditions' => '',
> 'order' => 'Rundate.run_date ASC',
> 'limit' => '',
> 'unique' => true,
> 'finderQuery' => '',
> 'deleteQuery' => '',
> 'insertQuery' => ''
> )
> );
>
> }
>
> class AdsRundate extends AppModel {
> var $name = 'AdsRundate';
> var $belongsTo = array(
> 'Ad' => array('className' => 'Ad',
> 'foreignKey'
> => 'ad_id',
> 'conditions'
> => '',
> 'fields' =>
> '',
> 'order' => '',
>
> 'counterCache' => ''),
> 'Rundate' => array('className' => 'Rundate',
> 'foreignKey'
> => 'rundate_id',
> 'conditions'
> => '',
> 'fields' =>
> '',
> 'order' => '',
>
> 'counterCache' => ''),
>
> );
>
> }
>
> In this app, to filter by the extra fields in the join tables, I've
> created methods in the join table models. I could call these as
> expected e.g. $this->JoinTableModel->customMethod() which would return
> the records for the join table, and its related tables records. These
> methods worked fine until I upgraded my core from 1.2.0.7296 RC2 to
> 1.2.2.8120. Now in some cases methods are not found. In other cases,
> only the record for the join table is returned, and none of the
> records in the belongsTo relations are returned, regardless of the
> recursion level set.
>
> It seems like my models are being ignored and auto-generated models
> are being used instead. Any suggestions on how I can make this work
> again?
>
> Thanks,
>
> Jeff
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---