If duplicate title, add rand else, do nothing??
Basic stuff, maybe but I jsut can't figure it out? Can someone help me here?
If duplicate title, add rand numbers, if not duplicate title then do nothing. That's easy but when I need to check if that modifyed title isn't also duplicate I hit the wall..
Here's code (codeigniter):
Thanks for all help!
Your question isn't very descriptive. What are you doing in the first place?
I'm converting title as product url which i will then insert into product table in database. eg. "Fast computer whit awesome monitor" would be "fast-computer-whit-awesome-monitor".
If users are adding same title for products, we'll add end of url some random numbers eg."fast-computer-whit-awesome-monitor-86553". When generating that random number, how do I check that there is not url whit same random number in place?
The same way you would check whether or not you needed to generate the random number for duplicate titles in the first case. Make it a function, 'check_duplicate()' and run it once to see if the number needs to be generated, and again to make sure the generated number isn't already in there.
Or take a page from WordPress and generate it in numerical order. Find the last title, 'some-duplicate-title-2' and add 1 to it.
|All times are GMT. The time now is 04:06 PM.|
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0