Pieduriens Posted June 17, 2013 Report Share Posted June 17, 2013 (edited) Sveiki.. Mācību ietvaros cīnos ar vienu loģisko algoritmu.. http://pastebin.com/D3N38Gas Vēlos iestāstīt, ka pie nosacījuma, ja šāda vērtība eksistē piekabina klāt stringam +1... Analoģiski kā WP, kur, ja slugs eskistē, tad WP pats pielik klāt unikālu galotni... Pašlaik strādā līdz trešajai reizei.. 1) adrese 2) adrese-2 3) šo jau rāda tā pat: adrese-2, (vajadzētu adrese-3 utt...) Ceru, ka problēmu var saprast... Paldies... Edited June 17, 2013 by Pieduriens Quote Link to comment Share on other sites More sharing options...
waplet Posted June 17, 2013 Report Share Posted June 17, 2013 (edited) $query = $CI->db->query("SELECT * FROM $table WHERE slug = '$slug'"); varētu pamēģināt $query = $CI->db->query("SELECT * FROM &table WHERE slug LIKE '$slug%'"); $count = $query->num_rows(); if ($count > 0 ) { $slug .= '-'.$count; } return $slug; Edited June 17, 2013 by waplet Quote Link to comment Share on other sites More sharing options...
Pieduriens Posted June 17, 2013 Author Report Share Posted June 17, 2013 (edited) Ok, paldies Waplet.. Strādā.. Tikai aizstāju FROM &table WHERE ar $table. Bet jautājums: ko izdara tas procentiņs: '$slug%' ? Edited June 17, 2013 by Pieduriens Quote Link to comment Share on other sites More sharing options...
rpr Posted June 17, 2013 Report Share Posted June 17, 2013 tā ir sql like sintakse. Quote Link to comment Share on other sites More sharing options...
waplet Posted June 17, 2013 Report Share Posted June 17, 2013 (edited) Tas nozīmē, ka aiz vārda , ko satur mainīgais $slug, var būt vēl jebkāda garuma teksts. Edited June 17, 2013 by waplet Quote Link to comment Share on other sites More sharing options...
Pieduriens Posted June 17, 2013 Author Report Share Posted June 17, 2013 Vēlreiz paldies, tāda sīka lietiņa, bet tik daudz izručī ;) Quote Link to comment Share on other sites More sharing options...
waplet Posted June 18, 2013 Report Share Posted June 18, 2013 Atceries, ja tev būs divi linki ar vienādiem līdzīgiem slug'u sākumiem, var kaut kas šķībi aiziet :D Quote Link to comment Share on other sites More sharing options...
yuugen Posted July 7, 2013 Report Share Posted July 7, 2013 off topic, bet courserā sācies algoritmu kurss, varbūt noder c: https://class.coursera.org/algo-004/class/index Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.