daGrevis Posted March 13, 2010 Report Share Posted March 13, 2010 (edited) Laba diena, Ko jūs domājat par šādu metodi pieprasījumu skaitīšanai... $queries = -1; // Set $queries. // Some code. //mysql_query(); $queries++; // Some code. //mysql_query(); $queries++; // Some code. function foo() { global $queries; // Šis man nepatīk! /dG/ //mysql_query(); $queries++; echo 2 + 2; } // Some code. if($queries > 0) { $queries = 0; } echo 'Page loaded with ' . $queries . 'queries.'; Edited March 13, 2010 by daGrevis Quote Link to comment Share on other sites More sharing options...
briedis Posted March 13, 2010 Report Share Posted March 13, 2010 Ja ar kvērijiem tiktu galā kāda OOP klasīte, tad būtu daudz plašākas iespējas... Pie topika "Noderīgas funkcijas" biju iemetis vienu skriptu, kas overraido mysql_query, un tur var redzēt cik kvēriji izpildās un cik ilgi katrs no tiem... Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 13, 2010 Report Share Posted March 13, 2010 (edited) Man ar šī lieta pašlaik ir aktuāla, bet es vnk izveidoju fju. // def vars $queries_count = 0; function query($sql) { global $queries_count; mysql_query($sql); $queries_count++; } // pieprasam kko. $username = query("SELECT uname FROM table WHERE ID = ID"); echo "Lapā ir ".$queries_count." kvēriji"; Edited March 13, 2010 by anonīms Quote Link to comment Share on other sites More sharing options...
2easy Posted March 13, 2010 Report Share Posted March 13, 2010 Man ar šī lieta pašlaik ir aktuāla, bet es vnk izveidoju fju man prieks, ka te ir arī kāds, kurš domā sakarīgi :)) vienkāršām lietām vienkārši risinājumi... Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 13, 2010 Report Share Posted March 13, 2010 Neaizmirsti return $q = mysql_query($sql); return $q; Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 14, 2010 Author Report Share Posted March 14, 2010 man prieks, ka te ir arī kāds, kurš domā sakarīgi :)) vienkāršām lietām vienkārši risinājumi... Tas jau bija uzbrauciens. :D Quote Link to comment Share on other sites More sharing options...
2easy Posted March 14, 2010 Report Share Posted March 14, 2010 Tas jau bija uzbrauciens. :D tā bija uzslava anonīms par to, ka nesarežģī vienkāršas lietas (pretēji tam, kas te bieži notiek) ;) Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 14, 2010 Author Report Share Posted March 14, 2010 (edited) Es tomēr gribētu zināt, kā anonīms versija var būt vieglāka par manējo?? :) Edited March 14, 2010 by daGrevis Quote Link to comment Share on other sites More sharing options...
2easy Posted March 14, 2010 Report Share Posted March 14, 2010 hmm, vnk viņš to noformēja un pasniedza visiem saprotamāk. no tava "foo" sazin ko var padomāt... :D:D:D Quote Link to comment Share on other sites More sharing options...
daGrevis Posted March 14, 2010 Author Report Share Posted March 14, 2010 hmm, vnk viņš to noformēja un pasniedza visiem saprotamāk. no tava "foo" sazin ko var padomāt... :D:D:D Mle, kas tev pret foo??! :D :D :D Mana versija. $queries = 0; $queries++; echo $queries; Quote Link to comment Share on other sites More sharing options...
anonīms Posted March 14, 2010 Report Share Posted March 14, 2010 lieki jāraksta $queries++; es savā variantā uzrakstu par 6 burtiem mazāk (query > mysql_query) ^^ 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.