CakePHP model belongs to any other model -


i not sure correct title. here problem:

there several models such as:
company
person (not same users)
user
etc.

some of them needs have 1 or more files attached them.

so have created uploadedfile model. how link of above models? uploadedfile belongs company. uploadedfile belongs person

if uploadedfile belongs company, doesn't belong others person.

all uploadedfile belongs user (because upload them , need track uploaded it)

does habtm works here? other better ways?

thank help.

best regards,
tony.

make uploadedfile belog 3 (user, company , person):

var $belongsto = array(     'user' => array('classname' => 'user','foreignkey' => 'user_id'),     'company' => array('classname' => 'company','foreignkey' => 'company_id'),     'person' => array('classname' => 'person','foreignkey' => 'person_id')); 

since belong user, user_id have value.

then check whether company_id set or person_id set , determine of them file belongs. have application works this. bit painstaking, not find other solution

another idea try , combine person , company in single table, , have flag distinguish between two.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -