tags:

views:

50

answers:

0

I have this php function wich generate name from title which contains polish local characters like ł,ó,ż,ć

function safe_name($name) {
  $chars = array('ą' => 'a', 'ż' => 'z', 'ź' => 'z', 'ś' => 's', 'ć' => 'c', 'ó' => 'o', 'ł' => 'l',  ' ' => '-', '"' => '-', "'" => '-');
  $result = strtr(strtolower(trim($name)), $chars);
  return preg_replace('/-+$/', '', preg_replace('/-+/', '-', $result));
}

and I generate url with this function <a href="post.php?name=' . safe_name($title) . '">'

which generate url like post.php?name=url-safe-name-function-in-mysql

and in post.php I have this SQL select.

SELECT title, safe_name(title) as name, content FROM post WHERE name = '$name'

how can I crate safe_name function in MySQL.