I've read the post referenced above multiple times and have not had any
luck implementing a solution. I've revised my data model slightly to
make it easier to read.
------------------------------------------------------------------------------------
//Database
Attendees --> Attendees-Sessions <---- Sessions
|
|
V
__________________
| attendee_id |
| session_id |
| score |
|__________________|
------------------------------------------------------------------------------------
//Models
class Attendee extends AppModel
{
var $name = 'Attendee';
var $useTable = 'attendees';
var $primaryKey = 'id';
var $hasMany = array( 'attendees_sessions' =>
array( 'className' =>
'Attendees_Session',
'foreignKey' =>
'attendee_id' ) );
var $recursive = 2;
} // class Attendee
class Session extends AppModel
{
var $name = 'Session';
var $useTable = 'sessions';
var $primaryKey = 'id';
var $hasMany = array( 'attendees_sessions' =>
array( 'className' =>
'Attendees_Session',
'foreignKey'
=> 'session_id' ) );
var $recursive = 2;
} // class Session
class Attendees_Session extends AppModel
{
var $name = 'Attendees_Session';
var $useTable = 'attendees_sessions';
var $belongsTo = array( 'attendees' =>
array( 'className' => 'Attendee',
'foreignKey' =>
'attendee_id'),
'sessions' =>
array( 'className' => 'Session',
'foreignKey' =>
'session_id') );
} // class Attendees_Session
------------------------------------------------------------------------------------
When I apply the code above I am able to scaffold the
attendees_session.php model, but I am not able to add new rows to the
attendees_sessions table. The scaffolding add screen refreshes but
does not advance to another page when I click on Save. Checking the
database shows that no rows were added. I did define a
$hasAndBelongsToMany in my attendee model at the same time (by
accident) and was able to add a new row surprisingly.
Also, how do I define two Primary Keys in the Attendees_Session model?
When I attempt to declare two PK's on the same line I receive the
following error:
"Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING,
expecting T_VARIABLE in
sys:/www/training_cake/app/models/attendees_session.php on line 9"
Thanks!
Devo
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---