PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
It is currently Mon Feb 24, 2020 11:05 pm

All times are UTC - 5 hours

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Feb 19, 2012 7:30 am 
Forum Contributor

Joined: Tue Feb 16, 2010 6:39 pm
Posts: 254
This is a sort of general question that applies to several areas of my application development.

Say I have an object that is related to a bunch of other objects, and the relations are held in a MySQL table called "relations", with columns for "first_object", "second_object", and, let's say "relation_order". The user can go in and modify the first object, and there can edit the list of relations it has with other objects by removing and re-ordering list items. When the user has modified the list, I have two options. One, I can just delete all relations that this object has with any second object, and then create them all from scratch. Two, I can go through all existing relations and all new relations, find the ones to delete and create with array_diff and array_intersect, and go from there. I have done this both ways in various parts of my applications and haven't noticed any real difference in speed, but it could potentially be noticeable if their databases grow substantially.

Is there a clear benefit to either one of these methods? Or maybe it depends on the situation? I'd like to hear thoughts.


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group