loyd Posted October 31, 2008 Report Share Posted October 31, 2008 Vai ir kāda iespēja, kā es varētu redzēt pilnīgi visus querijus, kas izdariiti uz mysql serveri? Nezinu varbūt jau tada funkcija man ir pieejama kaut kur, vai arī ja nav kā to varētu uztaisīt? Link to comment Share on other sites More sharing options...
andrisp Posted October 31, 2008 Report Share Posted October 31, 2008 http://www.google.com/search?hl=en&q=mysql+log Link to comment Share on other sites More sharing options...
codez Posted October 31, 2008 Report Share Posted October 31, 2008 (edited) Vienkāršā variantā daram aptuveni šādi: <?php class db extends mysqli { private static $instance; private function __construct() { parent::__construct(DB_HOST,DB_LOGIN,DB_PASS, DB_DB); $this->set_charset("utf8"); } //================ PUBLIC ===================== // get Instance of db singleton public static function I() { if (!self::$instance instanceof self) { self::$instance = new self; } return self::$instance; } public function dbQuery($query) { var $start_time = microtime(); $result = self::query($query) or die(self::I()->error); var $end_time = microtime(); self::logquery($query,$end_time-$start_time,$result); return $result; } public function logquery($query,$time,$result){ //šeit logojam kā un ko gribam. } } Izmantojam: db::I()->dbQuery('SELECT 1'); Edited October 31, 2008 by codez Link to comment Share on other sites More sharing options...
loyd Posted November 1, 2008 Author Report Share Posted November 1, 2008 Ka man vinu iedarbinaat? db::I()->dbQuery('SELECT 1'); Link to comment Share on other sites More sharing options...
cucumber Posted November 1, 2008 Report Share Posted November 1, 2008 diezvai ir sapratigi katru vaicajumu veidot ka jaunu objektu labak klase nodefinet mainigo, kas skaita cik reizes query ir izpildits un, attieciga vieta izsaukt to metodi, kas atgriez sho attributu. class cntTest{ private $qCnt; public function fakeQuery(){ $this->qCnt++; //make query } public function getCnt(){ return $this->qCnt; } } $x = new cntTest(); $x -> fakeQuery(); $x -> fakeQuery(); $x -> fakeQuery(); echo $x -> getCnt(); //3 Link to comment Share on other sites More sharing options...
bubu Posted November 1, 2008 Report Share Posted November 1, 2008 cucumber: un kur tur iepriekš uz katru vaicājumu tiek taisīts jauns objekts? Tur uz katru ir viens un tas pats. Autoram pie tam nevajag jau skaitu, bet gan pašus kverijus. Un tieši to arī Java's kods dara. Link to comment Share on other sites More sharing options...
cucumber Posted November 2, 2008 Report Share Posted November 2, 2008 tad metodi vajadzetu bik pielabot public function fakeQuery($qeury){ $this->qCnt[] = $qeury; //make query } Link to comment Share on other sites More sharing options...
andrisp Posted November 2, 2008 Report Share Posted November 2, 2008 cucumber, kāpēc veidot atsevišķu klasi priekš logošanas ? Link to comment Share on other sites More sharing options...
cucumber Posted November 2, 2008 Report Share Posted November 2, 2008 Lai varetu veikt dazadus logus, manis pec, var f-ju vai vienkarshi masiva ierakstit pirms izsaukt vaicajumu. Link to comment Share on other sites More sharing options...
Recommended Posts