Understanding Kohana ORM Relationships -


I know that this question has been asked for a million times, but I think that really good to me

I have a database with 5 tables:

  accepted_summation-submission_ad favorite favorite-username_id -submission_id ratings -user_id -submission_id just,  favorites ,  ratings , and  votes    / code> is a primary key that contains each column in the table, so that a user can Mr. code several times to stop favoriting, the same user voting  submission_id  times more. I also believe that these areas are set using the foreign key which is the reference  approved_submission  and  user  in order to prevent invalid data in related areas .  

Using the DB module, I can not have any problems reaching and updating these tables. I really feel that the ORM can provide a more powerful and accessible way to complete the same things by using less code.

Can you show me a submission_id ? Removing user favorite submission_id ? Is a user changing his rating on a particular submission_id ?

In addition, do I need to change my database structure or is it OK?

You are probably looking for relationships.

So to add a new submission, you want something like

  $ user-> Add ('Submissions', $ Submissions);   

To remove more

  $ user-> Remove ('Submissions', $ Submissions);   

You may want to consider restructuring your database tables and key names, so that you can do a lot of configuration.

Comments