I was just reading the documentation on model associations... I need
HABTM associations to use a join table...



On Aug 16, 6:48 pm, Josh <[email protected]> wrote:
> Hi,
>
> I am setting up the tables/models for a new app and I've hit a
> sticking point. I am setting up three tables right now:
>
> datatypes: This table provides a list of  the names incoming data
> types.
>
> datatypes_validations: This table links the two, allowing data types
> to have multiple validation functions.
>
> validations: This table provides a list of Cake validation functions
> and custom functions.
>
> I have my models set up in the following way: The DatatypesValidation
> model has the foreign keys for both the Datatype and Validation model.
> The relations are hasMany, belongsTo between the DatatypesValidation
> model and the Datatype/Validation models respectively.
>
> I can't seem to bake controllers and views without getting errors.
>
> First of all, should this work? Secondly, is there a better way to set
> this up? The console points me in the direction of HABTM relations;
> does it make sense to set this up with HABTM?
>
> Model Classes:
>
> class Datatype extends AppModel {
>         var $name = 'Datatype';
>         var $validate = array(
>                 'name' => array('notEmpty')
>         );
>         var $actsAs = array('Tree');
>         var $hasMany = array('DatatypesValidation');
>
> }
>
> class DatatypesValidation extends AppModel {
>         var $name = 'DatatypesValidation';
>         var $validate = array(
>                 'datatype_id' => array('numeric'),
>                 'validation_id' => array('numeric')
>         );
>
>         var $belongsTo = array('Datatype', 'Validation');
>
> }
>
> class Validation extends AppModel {
>         var $name = 'Validation';
>         var $validate = array(
>                 'name' => array('notempty')
>         );
>         var $hasMany = array('DatatypesValidation');
>
>
>
> }
--~--~---------~--~----~------------~-------~--~----~
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