I have a legacy database and I am unfotunately unable to change the
table structure.

I have the following tables:
CODE
scheduled_models   (no primary key set, but should be model_id)
   model_id    int(11)  auto_increment
   model_name  varchar(15)
   ... and other fields

and:
CODE
schedule_dates  (again no primary key, but should have a separate id
field)
   date        datetime
   model_name  varchar(15)

and:
CODE
scheduled_pics   (again no primary key set, but should be pic_id)
   pic_id      int(11)
   model_name  varchar(15)
   .... and other fields


I have a model for each and I am trying to link them together. The
relationships should be (as best I understand) a scheduled_model
belongsTo schedule_date, a schedule_date hasMany scheduled_model, a
scheduled_model hasMany schedule_pic and a scheduled_pic belongsTo a
scheduled_model.

Nothing I have tried works and I think part of it is because the
tables have no primary keys defined, and part because the foreign keys
are a little odd.

Currently, my models are as follows:
PHP Code
<?php
class ScheduledModel extends AppModel{
  var $name = "ScheduledModel";

  var $belongsTo = array('ScheduledDate' =>
                     array ( foreignKey => false,
                             conditions  => array
(’ScheduledDate.model_name’ => ‘ScheduledModel.model_name’)));
  var $hasMany = "ScheduledPic";
}
?>

PHP Code
<?php
class ScheduleDate extends AppModel{
  var $name = "ScheduleDate";

  var $hasMany = array('ScheduledModel' =>
                     array ( foreignKey => false,
                             conditions  => array
(’ScheduledModel.model_name’ => ‘ScheduledDate.model_name’)));
}
?>

PHP Code
<?php
class ScheduledPic extends AppModel{
  var $name = "ScheduledPic";

  var $belongsTo = "ScheduledModel";
}
?>


Please help with getting these relationships defined. I am a beginner
with cakePHP, and remember they are lagacy tables so cannot be
changed.

Thanks

Maree

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to