On Oct 13, 6:50 am, CakeONaut <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I have a model query - at first I thought it was recursive but when I
> found such references in the cakephp manual I think perhaps not.
>
> The situation is this: I have one table with many tabs. There is
> another table full of renovation images that I want displayed when
> people click on a tab on a site I've set up.
>
> So I'm going to pair the tabs (via admin point-and-click) with photos
> and then the site will be updated and my friend who owns the
> renovation company will stop asking me to update his site because he
> can do it almost instantly.
>
> I need help with the following table (the foreign key comes from an
> "img" table containing around 70 photos).
>
> Two questions:
> 1) How can I avoid my dumb tabA, tabB, tabC, etc.? It would be better
> to set this model up as id, tab, img_id (foreign key) and somehow make
> the model employ a loop so that with 1 form I can associate the 15 or
> so tabs with photos.
> 2) Given any suggestion as to how to set up the Tabitem class, what
> will the foreign key from class Img (which has the images or photos)?
>
> Thanks heaps!
>
> -Will
>
> =========== SNIP ==============
> <?php
> class Tabitem extends AppModel
> {
> var $name='Tabitem';
>
> var $hasOne= array ('img' =>array(
> 'className' => 'Tabitem' ,
> 'tabA' => 'tabA',
> 'img_idA' => 'img_idA',
> 'tabB' => 'tabB',
> 'img_idB' => 'img_idB',
> 'tabC' => 'tabC',
> 'img_idC' => 'img_idC',
> ETC.
> 'created' => 'created',
> 'modified' => 'modified',
> 'foreignKey'=>'WHAT GOES HERE?')
> );
> }
> ?>
You are going to need to try and explain again, in the above hasOne
defenition what are all these img_idA etc. keys which cake will
dutifully ignore? Is your question about forms with multiple (same
class) items or associations? if you have n images why don't you have
a hasMany association to images?
Cheers,
AD
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---