0

i have different objects with there id's, all id's are unique.

objects

  • photo
  • feed
  • event
  • comment

all of there id's are unique and never repeated again.

i want to pass that id in url like this: http://domain.com/{object_id} and object id should tell me, which object it belongs to and what it id is. maybe doing it through php.

i read somewhere that it can be done it through base_convert with prepending text or different id. not sure.

edited:

current ids and url

lets say we are on this page http://domain.com/654156165165, how would we know if this is id of photo, feed, event or comment?

solution 1 i was thinking about

  • reproduce the id with prepend/append some integer, to identify which object it belongs to
  • page is requested with new id http://domain.com/654646545412
  • check with php which object this id belongs to and what was the actual id of that object (after removing prepended/appended integer)
Basit
  • 16,316
  • 31
  • 93
  • 154
  • Touch to understand what you're trying to achieve. Give us some examples of what you want the URLs to look like, e.g., what does a photo URL look like, what does a feed URL look like, etc. – webbiedave Apr 23 '13 at 15:23
  • So, what's the problem here? Getting {object_id} from URL ? – cipher Apr 23 '13 at 15:23

2 Answers2

0

Just query a database for the object details. I am sure you have object type stored there.

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • in order to find one object, i would have to query each table until i find which object it belongs to and it's just too much overhead for many many objects. – Basit Apr 23 '13 at 15:37
  • should i create separate table for objects? whenever a row is created with id, then insert that row id with type in object table? do you prefer that? – Basit Apr 23 '13 at 15:53
  • Either your ids are indeed unique - and thus you have a single table to hold all the objects, or you don't need through uniqueness, but have to use separate sequences for different types. – Your Common Sense Apr 23 '13 at 15:55
  • on every insert, it will be two inserts. one for actual row and one for object table. is that fine? – Basit Apr 23 '13 at 16:51
  • May be. It's hard to tell from such a limited data. You'd better ask a separate question for advise on a database structure. – Your Common Sense Apr 23 '13 at 17:14
0

You should query the database for the object. You mention that this is prohibitive due to overhead however with proper indexing this shouldn't be to bad as long as you include the WHERE id = :objectID in your queries. Alternatively you could create an object table which has all of the ID's along with the type of object they are, query that for the object, then query only the appropriate table.

Joe Meyer
  • 4,315
  • 20
  • 28