Grant,
I set this up, removed the ''Image.is_archived' => 0' in the
conditions, as s/th like this is not implemented here yet (or is it
some standard I oversee), and changed 'Image.foreign_model'=>'Article'
to the plural, so I can use it (as far as I can see now) with a form
called by renderElement from anywhere where this data is set like:
$html->hidden('images/foreign_model', array('value' => $this->name));
Like this I should be able use this renderElement all over the place.
[am I right here?]
One more question, as this is my first cake backed, and I would like
it to shine:
As this solution seems to be a real bassplayer-style (!) I would like
to use it on comments, or tags, or xyz too.
Again performance: What if there are hundreds of images, every image
having, lets say 'quite a lot' of comments. Or many many articles,
images, whatever having many many tags (Tags implemented the same
way).
Would it be more clever to separate data into different tables
(comments for Images, for Articles etc...) [from HABTM-point-of-view
not necessary] or can: a 'standard' mysql (latest 4.x), php4 and cake
(1.1) handle this?
Bassy regards,
Benjamin
On Sep 22, 4:03 pm, bigbass <[EMAIL PROTECTED]> wrote:
> Grant,
>
> thank you!
> My app doesn't need a HABTM relationship for images, as far as it it's
> layout looks like now.
> I thought of adding fields for foreign_model and foreign_id myself,
> your post showed me I was on the right track.
>
> Bassy regards,
> Benjamin
>
> On Sep 22, 5:43 am, Grant Cox <[EMAIL PROTECTED]> wrote:
>
> > HABTM vs hasMany depends on your application functionality - between
> > an article and an image is it hasMany (each image is only in one
> > article), or HABTM (each image could be in multiple articles)? The
> > table setup will follow these application requirements, not the other
> > way round.
>
> > If you can have a single table, do it. I would recommend each Image
> > having a field "foreign_model" and "foreign_id", and the association
> > from Article would be:
>
> > var $hasMany = array(
> > 'Image' => array(
> > 'className' => 'Image',
> > 'conditions' => array(
> > 'Image.foreign_model'=>'Article',
> > 'Image.is_archived' => 0
> > ),
> > 'foreignKey' => 'foreign_id',
> > 'dependent' => true,
> > ),
> > );
>
> > This way the one Image table can store images used for any other
> > associations.
>
> > On Sep 22, 9:57 am, bigbass <[EMAIL PROTECTED]> wrote:
>
> > > Hi there,
>
> > > I'm setting up a new site with cake 1.1. As a cake-newby, maybe you
> > > could give me your 5 cents (or even more? :) :
> > > The site uses user-generated images in different places (user profile,
> > > galeries, articles etc)
> > > I'm thinking of setting up just one table which stores image
> > > information (meta's etc) and joining this table via HABTM (eg.
> > > articles_images to the refering table articles). Is this a good
> > > practice in cake, or in general? Or would it be more efficient (and
> > > more resource-friendly) to use separate tables for each referer, as a
> > > HasMany relation (articles HasMany articleImages). Which models would
> > > be faster concerning requests?
>
> > > Best regards,
> > > thanks for your cents in advance,
> > > Benjamin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---