Welcome Guest, Not a member yet? Register   Sign In
Slugs - Help me to understand

[eluser]Mauricio de Abreu Antunes[/eluser]
Hello, i'm trying to understand slugs.


This post tells me to insert my new with a slug like 'help-me-with-slugs'.
Ok, i understood this part. I can not understand how i can select data from a slug?
select * from news where slug = 'help-me-with-slugs';
Ok, i can get data from this, but when i insert a slug, it can be duplicated in the database. Is necessary to validate my title?

...where slug = 'help-me-with-slugs'
is not so good to the database.
Performing a query with no primary key like http://www.site.com/news/24/help-me-with-slugs
where 24 is 'help-me-with-slugs' ID.

And what about routes if i get 'help-me-with-slugs' pagination?


Post your question in the correct forum topic and you may get help!

This forum topic is for donate user code...

[eluser]Phil Sturgeon[/eluser]
A slug is simply a unique identifier that means more to a user than 459372 does. It also protects people from mining your data by incrementing a number in a URL and saving all your stuff, or being able to work out how many sales you are making a'la the ridiculous way Magento handle their sales.

You should be making your slugs unique, by either saying "this title is already taken" or by adding -2 to the end of the slug if you've found a match in the db.

Also make the field into an index key or your database will get SLOW.

Theme © iAndrew 2016 - Forum software by © MyBB