Welcome Guest, Not a member yet? Register   Sign In
ID in url
#1

[eluser]Keyur Shah[/eluser]
Wanted to find out what other were using for the unique id in your url?

for example, I have:

www.mysite.com/id/slug-name

I am only querying for id, regardless of the actual slug-name (i.e. blue-widget)

But I can simply use the primary_key of the product, but for future compatibility if I switch to another database, framework, etc, would I be better of using a generated id instead, and then query my records for that unique id.

So, if my primary_key is 10, instead of using 10 as the id, I can create a random number for each record, like 104567, and use that instead?
#2

[eluser]Otemu[/eluser]
Hi,

Most likely if you was to switch system you going to transfer your database so it wouldn't matter so much whether you are using auto incremented number, random number or inputted id, you would just incorporate the same functionality in your new system.

Normally I use auto incremented number for my unique id's within my database, with Codeigniter it is very easy to make friendly urls without using a id in your url, you could set a unique url name in your database and search for that instead of a id such as mysite.com/film/avengers-reloaded where avengers-reloaded is the unique url name.





Theme © iAndrew 2016 - Forum software by © MyBB