One table for uploads for multiple resources in CakePHP
Posted
by Mef
on Stack Overflow
See other posts from Stack Overflow
or by Mef
Published on 2010-04-07T07:14:40Z
Indexed on
2010/04/07
8:43 UTC
Read the original article
Hit count: 208
Hi,
I have CakePHP app in which I'd like to attach gallery to multiple resources. Let's say I've got artists, each one has own gallery. I've got articles, every article has some images attached to it and so on. Now I set up tables like this:
- Artists hasMany Artistimages, fields in
artistimages
table are:id, artist_id, filename, filetype, filesize
etc. - Articles hasMany Articleimages, fields in
articleimages
table are:id, article_id, filename, filetype, filesize
etc.
...but this is not how it should be, I think.
Is there possibility to have one table called for example uploads
which will contain all images with foreign key pointing to resource its reffering to? How to tell CakePHP which image is coming from which resource?
© Stack Overflow or respective owner