This was very helpful, thanks a lot. I'm very new to Cake and this explained
a good chunk I was confused about.


On Mon, Mar 7, 2011 at 5:41 PM, cricket <[email protected]> wrote:

> On Mon, Mar 7, 2011 at 6:16 PM, jphenow <[email protected]> wrote:
> > Okay so two questions very related:
> >
> > 1) Does following the naming convention for classes, controllers,
> database
> > fields, etc. affect the framework's ability to work the way it was
> > intended?
>
> It makes things simpler, although there are mechanisms for going
> against the convention. One can set Model::useTable, for example.
>
> > 2) This question is more important if 1 is a yes. Say I have a table that
> > has 2 foreign keys pointing at the same table but different entries
> (they're
> > like edges of a graph that point at two vertices) how would I follow the
> > naming convention of their database fields? All I can think to do is
> > something like vertex_1_id and vertex_2_id but I don't know how the
> > framework would handle that if the naming conventions are necessary for
> its
> > functioning correctly.
>
> To establish associations between models, one uses an alias for the
> array key, then provide the class name inside the array, like so:
>
> public $hasOne = array(
>        'SomeAlias' => array(
>                'className'  => 'ActualClassName',
>                ...
>        )
> );
>
> Usually, alias and className will be the same. But, having an alias
> alows us to create multiple associations to the same class. We can
> also provide the FK column name in the association. So, in your case,
> you might do something like:
>
> public $hasOne = array(
>        'MinPoint' => array(
>                'className'  => 'Vertice',
>                'foreignKey' => 'min_vertice_id',
>                'dependent' => true
>        ),
>        'MaxPoint' => array(
>                'className'  => 'Vertice',
>                'foreignKey' => 'max_vertice_id',
>                'dependent' => true
>        )
> );
>
> And the table for YourClass would have both min_vertice_id and
> max_vertice_id FKs that point to a vertices.id (Vertice.id)
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to