I have a URL like
http://abc.com/users/index/University of Kansas and i want to make it University-of-Kansas. How is it possible via mysql using Cakephp ???
I have a URL like
http://abc.com/users/index/University of Kansas and i want to make it University-of-Kansas. How is it possible via mysql using Cakephp ???
I'm not sure how your data is being populated, but you probably want to store a tag, or slug field along with the full title. So your database would have both "University of Kansas" and also "University-of-Kansas" in a separate field. When you save an entry, you can auto-generate the latter field w/ a regex such as:
$slug = preg_replace("/[^-_0-9A-Za-z]/", "-", $title);
Depending on how your CakePHP is set up, you'd probably want to create a route that passed this slug value into the controller, so you could then look up the right entry in the database using that field.
Use can use the Cake built in Inflector::slug($data, '-');
Source: http://api.cakephp.org/class/inflector#method-Inflectorslug
So you would get the string "University of Kansas" from the $this->params['url']:
$data = $this->params['url'][....]:
$slug = Inflector::slug($data, '-');
http://cake-syrup.sourceforge.net/ingredients/sluggable-behavior/
This is a behavior that allows your model to create slugs when records get saved or edited.