Aleksejs Posted February 23, 2009 Report Share Posted February 23, 2009 nu parādi,ko tu dari, kad pievieno. Quote Link to comment Share on other sites More sharing options...
Delfins Posted February 23, 2009 Report Share Posted February 23, 2009 komentāru skaitu nevis inkrementē, bet saskaiti. To biš pie INSERT/DELETE uztaisīt trigeri (vai PHP kodā) Quote Link to comment Share on other sites More sharing options...
goma smile Posted February 23, 2009 Author Report Share Posted February 23, 2009 Šeit Kodu daļa no pievienošanas un dzēšanas Saku uzreiz, ka varētu būt nodiršams jo esu maziņš noobāriņš :D Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 24, 2009 Report Share Posted February 24, 2009 Pamēģini pirms izpildīšanas izvadīt (ar echo), kādi tie vaicājumi sanākuši. Un katru mysql_query(...); pārveido par mysql_query(...) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Web Developer Posted February 24, 2009 Report Share Posted February 24, 2009 Tev tur jātaisa trigeris, gribi negribi... Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 24, 2009 Report Share Posted February 24, 2009 Hmm, bet kāpēc trigeris obligāti? Nē, nu es nenoliedzu - ar trigeri tas viss darbotos uzticamāk. Bet var taču arī INSERT/UPDATE un DELETE/UPDATE. Jo ja grib, lai viss vienmēr būtu aktuāls, tad vispār pilnīgi visas lietas jātaisa ar transakcijām. Quote Link to comment Share on other sites More sharing options...
Klez Posted February 24, 2009 Report Share Posted February 24, 2009 (edited) 1) kad dzēš, tad $dzes = mysql_query("DELETE FROM komentaari WHERE id={$_GET['a']} LIMIT 1"); if (mysql_num_rows($dzes) > 0) mysql_query("UPDATE jaunumi SET komentaaru_skaits=komentaaru_skaits - 1 WHERE id='{$_GET['id']}'"); un tā pat ar insert ..... Edited February 24, 2009 by Klez Quote Link to comment Share on other sites More sharing options...
Web Developer Posted February 24, 2009 Report Share Posted February 24, 2009 Trigeris jātaisa, jo labāk to risināt datubāzes līmenī. Plus vēl tas, ja kādam ienāks prātā phpMyAdminā kaut ko dzēst, viņš nesabojās datus :) Tikpat labi - kāpēc vajadzīgi FK? To tak arī kodā var norādīt - tās saites - vienkārši veidojot kverijus. Bet tā nav garantija, kamēr DB līmenī izveidots FK ir garantija. Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 24, 2009 Report Share Posted February 24, 2009 Nu, tam es piekrītu, vienīgi esmu saskāries ar tiem pašiem ļaunajiem hostētājiem, kas visādas storētās procedūras trigerus utt neļauj taisīt. Quote Link to comment Share on other sites More sharing options...
Web Developer Posted February 24, 2009 Report Share Posted February 24, 2009 Aleksejs - serveris.lv ? Nevajag pie tādiem iet tad. Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 24, 2009 Report Share Posted February 24, 2009 Web Developer, nē - nav serveris.lv Quote Link to comment Share on other sites More sharing options...
Delfins Posted February 24, 2009 Report Share Posted February 24, 2009 update X set C = (select count() from Y where Y.id = x) where X.id = x Quote Link to comment Share on other sites More sharing options...
goma smile Posted February 24, 2009 Author Report Share Posted February 24, 2009 Nekādīgi nesanāk vinalga ko es daru dzēšu vai pievienoju monetāru komentāru_skaits iet tikai - Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted February 24, 2009 Report Share Posted February 24, 2009 Vai nav tā, ka 6. rindiņā esošā pārbaude ir true arī tad, ja $_GET['a'] nav uzstādīts vai ir tukšs: if(preg_match('/^[0-9]*$/i', $_GET['a'])) Kas notiek, ja nomaini uz: if(preg_match('/^[0-9]+$/i', $_GET['a'])) ? un Pamēģini pirms izpildīšanas izvadīt (ar echo), kādi tie vaicājumi sanākuši. Quote Link to comment Share on other sites More sharing options...
Klez Posted February 24, 2009 Report Share Posted February 24, 2009 un varu piebilst pie Aleksejs teiktā: pārbaudi katru kveriju secīgi caur phpmyadmin un paskaties vai kaut kas notiek ... 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.