I've had the most success with HABTM-through by not trying to get CakePHP 
to do so much magic on the relationships.

So I would simply name the table "restrictions" and have it contain

id, attraction-id, attraction_accessibility_id, plus extra stuff

With Containable behavior I think you can get this wired up the way you 
want:

Search for attraction with 
$options = array('contains' => array('Restriction' => 
array('AttractionAccessibility')))

and you should get the attached accessibilities and extra data from the 
restriction.


On Friday, January 31, 2014 7:52:17 AM UTC-5, Sam Clauw wrote:
>
> After struggling with this inconvenience for a couple of weeks now, I've 
> decided to open en now topic here. A topic that can help me, but I'm sure 
> it will help some others with this same problem too!
>
> I wonder how I should name the tables, controllers and models of a hasMany 
> through table (thus with additional fields) and it's coupled tables. I 
> tried to stick on the CakePHP naming conventions as discribed in it's 
> cookbook, but this constantly gave me some "Object not found" errors. For 
> practical reason, I'll show you my problem with a many-words table. Perhaps 
> that could be the reason of the problem? ;)
>
> *Situation*
>
> I have a fansite of a themepark and as you now, a themepark has many 
> attractions. To ride an attraction, you must have a minimal height. 
> Sometimes, small people can only ride it with an adult companion. But most 
> of the time: you are allowed to ride the attraction because you just are 
> tall enough ;)
> Now I want to show the information of a specific attraction on my website. 
> Name, content, photos, and so on. In addition to that information, I want 
> to display my guests if they (or their kids) are tall enough to ride that 
> attraction. It should appear like this way:
>
> 0m00 -> 1m00: not allowed
> 1m00 -> 1m30: allowed with an adult companion
> 1m30 -> 1m90: allowed
>
> *Database*
>
> I have two tables that are representing two objects: "attractions" & 
> "attraction_accessibilities". In this case, I'm 100% sure the database 
> names are correct. Secondly, I should have another table between 
> "attractions" and "attraction_accessibilities". This table should contain:
>
>
>    - an id specific for each record
>    - a link to the id of the "attractions" table (attraction_id)
>    - a link to the id of the "attraction_accessibilities" table 
>    (attraction_accessibility_id)
>    - the additional information like "min-height" and "max-height"
>
> I *think* I should name that table 
> "attraction_accessibilities_attractions". It's a constriction of the two 
> other tables, and I did it that way because CakePHP proposed it when you're 
> making a HABTM association (
> http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm
> ).
>
> But unfortunately, when I do call it that way, I've never succeeded to 
> link those models in my application together.
>
> *Question*
>
> Is there anybody who've had the same problem but found a solution for it? 
> If "yes": how should I name my database tables then and also important: how 
> should I name my controller and model .php files?
> Many thanks for the one who could help me and some other hopeless 
> programmers ;)
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to