segunda-feira, 26 de outubro de 2015

MySQL Slugify

O CÓDIGO:

UPDATE `noticias_noticia`   SET slug = lower(titulo),
slug = replace(slug, '.', ' '),
slug = replace(slug,'ß','Ss'),
slug = replace(slug,'à','a'),
slug = replace(slug,'á','a'),
slug = replace(slug,'â','a'),
slug = replace(slug,'ã','a'),
slug = replace(slug,'ä','a'),
slug = replace(slug,'å','a'),
slug = replace(slug,'æ','a'),
slug = replace(slug,'ç','c'),
slug = replace(slug,'è','e'),
slug = replace(slug,'é','e'),
slug = replace(slug,'ê','e'),
slug = replace(slug,'ë','e'),
slug = replace(slug,'ì','i'),
slug = replace(slug,'í','i'),
slug = replace(slug,'î','i'),
slug = replace(slug,'ï','i'),
slug = replace(slug,'ð','o'),
slug = replace(slug,'ñ','n'),
slug = replace(slug,'ò','o'),
slug = replace(slug,'ó','o'),
slug = replace(slug,'ô','o'),
slug = replace(slug,'õ','o'),
slug = replace(slug,'ö','o'),
slug = replace(slug,'ø','o'),
slug = replace(slug,'ù','u'),
slug = replace(slug,'ú','u'),
slug = replace(slug,'û','u'),
slug = replace(slug,'ý','y'),
slug = replace(slug,'ý','y'),
slug = replace(slug,'þ','b'),
slug = replace(slug,'ÿ','y'),
slug = replace(slug,'ƒ','f'),
slug = replace(slug, 'œ', 'oe'),
slug = replace(slug, '€', 'euro'),
slug = replace(slug, '$', 'dollars'),
slug = replace(slug, '£', ''),
slug = replace(slug, '/', ''),
slug = replace(slug, ',', ''),
slug = replace(slug, ':', ''),
slug = replace(slug, '!', ''),
slug = replace(slug, '?', ''),
slug = replace(slug, '%', ''),
slug = replace(slug, '"', ''),
slug = replace(slug, "'", ''),
slug = replace(slug, '+', ''),
slug = replace(slug, '(', ''),
slug = replace(slug, ')', ''),
slug = replace(slug, '\\', ''),
slug = replace(slug, '“', ''),
slug = replace(slug, '”', ''),
slug = replace(slug, 'º', ''),
slug = replace(slug, 'ª', ''),
slug = trim(slug),
slug = replace(slug, ' ', '-'),
slug = replace(slug, '--', '-') ;

hasta!