Jump to content
php.lv forumi

Kā pārbaudīt cik Querijie ir lietoti?


Digital-X

Recommended Posts

Uztaisa mainiigo $querycount = 0; , kursh tiek palielinats $querycount++ katru reizi, kad tiek izpildiits kaads query, beigaas echo $querycount. Piemeeram, apmeeram shaadu funkciju var ievietot:

 

function query($query) {

$result = mysql_query($query);

if ($result) {

$querycount++;

return $result;

} else {

return FALSE;

}

}

Link to comment
Share on other sites

nu vispirms jau par Robis ieteikto funkciju - taa nestraadaas kaa tas bij domaats, proti, $querycount mainiigais ir funkcijas iekshienee un funkcija sho mainiigo nedz nodod nedz arii sanjem (ja nu vieniigi kaa globaalo, kas nav kruta)

 

to Digital-X:

saakumaa noliec mainiigo $querycount=0;

pie katra vaicaajuma palielini $querycount par viens, t.i., $querycount++;

varbuut, ka ir kaada php iebuuveetaa funkcija, kas to nosaka, bet taa kaa nav shaada lieta bijusi nepiecieshama, tad nezinaashu (uzmetot aci php.net neatradu).

Link to comment
Share on other sites

t.i.

$querycount=0;
$DB->query("SELECT * FROM ibf_admin_sessions WHERE ID='".$IN['adsess']."'");
$querycount++;
$DB->query("SELECT * FROM ibf_members WHERE id='".$row['MEMBER_ID']."'");
$MEMBER = $DB->fetch_row();
$querycount++;
$DB->query("SELECT * FROM ibf_groups WHERE g_id='".$MEMBER['mgroup']."'");
$GROUP = $DB->fetch_row();
$querycount++;
echo $querycount;

Shaadi? Tie queriji ir no IPB(par piemeeru)

Link to comment
Share on other sites

nu taa vismaz es dariitu...

ja jau tu darbojies ar objektiem, tad vari, protams, to mainiigo piesaistiit klasei etc.

class A {
var ...
var $querycount=0;
....
function countQuery() {
   $this->querycount+=1;  
   return ($this->querycount);
   }
}

un attieciigi:
$a = new A();
$DB->query("SELECT * FROM ibf_admin_sessions WHERE ID='".$IN['adsess']."'");
$a->countQuery();
$DB->query("SELECT * FROM ibf_members WHERE id='".$row['MEMBER_ID']."'");
$MEMBER = $DB->fetch_row();
echo $a->countQuery();

 

nu kaut kaa taa :)

Link to comment
Share on other sites

hu_ha, nu tu man pilniigi iznjeemi vaardus no mutes!!! Ideja jau maneejaa bija skaidra, vai ne??? Var jau uztaisiit arii shaadi (piemeers):

 

$DaTaBaSe->query("SELECT * FROM `table` ORDER BY `id`;");

 

 

Class DaTaBaSe() {

 

$querycount = 0;

 

function query($query) {

$result = mysql_query($query);

if ($result) {

query_count();

return $result;

} else {

return FALSE;

}

}

 

function query_count() {

$this->querycount++;

return $this->querycount;

}

}

 

echo $DaTaBaSe->query_count;

 

Atsevishkjaas daljas, ja cilveeks grib zinaat, kur jaaliek varu jau pateikt! Pirmkaart jau objekts DaTaBaSe ir nepilniigs, jo nepiecieshams veel piekonekteeties datubaazei utt.

Link to comment
Share on other sites

×
×
  • Create New...