yeni nesil webcilerin en cok ihtiyac duyduğu şeylerden biri sanırım (: seo için mysqlde bir fonksiyon ve auto seo yapan bir trigger.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | DROP FUNCTION IF EXISTS seo_yap $$ CREATE FUNCTION seo_yap(mix VARCHAR(255)) RETURNS varchar(255) BEGIN DECLARE seo_title VARCHAR(255); SET seo_title=REPLACE(mix,'i','i'); SET seo_title=REPLACE(seo_title,'ş','s'); SET seo_title=REPLACE(seo_title,'ö','o'); SET seo_title=REPLACE(seo_title,'ğ','g'); SET seo_title=REPLACE(seo_title,''',' '); SET seo_title=REPLACE(seo_title,'ü','u'); SET seo_title=REPLACE(seo_title,'ç','c'); SET seo_title=REPLACE(seo_title,'ü','u'); SET seo_title=REPLACE(seo_title,'ö','o'); SET seo_title=REPLACE(seo_title,'Ö','o'); SET seo_title=REPLACE(seo_title,'ş','s'); SET seo_title=REPLACE(seo_title,'Ş','s'); SET seo_title=REPLACE(seo_title,'Ç','c'); SET seo_title=REPLACE(seo_title,'ç','c'); SET seo_title=REPLACE(seo_title,'Ğ','g'); SET seo_title=REPLACE(seo_title,'ğ','g'); SET seo_title=REPLACE(seo_title,'Ü','g'); SET seo_title=REPLACE(seo_title,'İ','i'); SET seo_title=REPLACE(seo_title,'ı','i'); SET seo_title=REPLACE(seo_title,'I','i'); SET seo_title=REPLACE(seo_title,'ß','b'); SET seo_title=REPLACE(seo_title,'''',' '); SET seo_title=lower(seo_title); SET seo_title=REPLACE(seo_title,'{',' '); SET seo_title=REPLACE(seo_title,'(',' '); SET seo_title=REPLACE(seo_title,')',' '); SET seo_title=REPLACE(seo_title,'[',' '); SET seo_title=REPLACE(seo_title,'}',' '); SET seo_title=REPLACE(seo_title,']',' '); SET seo_title=REPLACE(seo_title,'=',' '); SET seo_title=REPLACE(seo_title,'?',' '); SET seo_title=REPLACE(seo_title,'&',' '); SET seo_title=REPLACE(seo_title,'%',' '); SET seo_title=REPLACE(seo_title,'*',' '); SET seo_title=REPLACE(seo_title,'.',' '); SET seo_title=REPLACE(seo_title,'|',' '); SET seo_title=REPLACE(seo_title,'\\',' '); SET seo_title=REPLACE(seo_title,'!',' '); SET seo_title=REPLACE(seo_title,'^',' '); SET seo_title=REPLACE(seo_title,'_',' '); SET seo_title=trim(seo_title); SET seo_title=REPLACE(seo_title,' ','-'); SET seo_title=REPLACE(seo_title,'----','-'); SET seo_title=REPLACE(seo_title,'---','-'); SET seo_title=REPLACE(seo_title,'--','-'); RETURN seo_title; END $$ |
Veritabanından çekerken yapmamız gerken alanı fonksiyon parantezleri içine almak
örneğin
0 | $db->sql("SELECT seo_yap(haber_basligi) as seo_baslik,haber_basligi as normal_baslik FROM haberler"); |
bir de bunu insert ve update anında kullanabilirsiniz seo başlık için bir alanınız varsa
otomatikleştirmek için de aşağıdaki örnek triggerlarla kendi triggerlarınızı yazabilirsiniz.
Örneğin WordPress php dosyalarında Seo yapmasaydı mysqlde seo_yap ve aşağıdaki triggerları kurulum anında yazmak yetecekti
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | DROP TRIGGER IF EXISTS seo_yap_insert $$ CREATE TRIGGER seo_yap_insert BEFORE INSERT ON wp_posts FOR EACH ROW BEGIN SET NEW.post_name=seo_yap(NEW.post_title); END $$ DROP TRIGGER IF EXISTS seo_yap_update $$ CREATE TRIGGER seo_yap_update BEFORE UPDATE ON mixes FOR EACH ROW BEGIN IF seo_yap(NEW.post_title) <> OLD.post_name THEN SET NEW.post_name=seo_yap(NEW.post_title); END IF; END $$ |
bunları sorgularken demiliterları $$ olarak değişirmeyi unutmayın (:








Teşekkürler çok güzel bir yazı.