1<?php 2 3/* 4 * This file is part of pgFouine. 5 * 6 * pgFouine - a PostgreSQL log analyzer 7 * Copyright (c) 2005-2008 Guillaume Smet 8 * 9 * pgFouine is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or (at 12 * your option) any later version. 13 * 14 * pgFouine is distributed in the hope that it will be useful, but 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with pgFouine; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 22 */ 23 24class QueryLogObject extends LogObject { 25 var $duration = false; 26 var $subQueries = array(); 27 28 function QueryLogObject($connectionId, $user, $db, $text = '', $ignored = false) { 29 if(DEBUG > 1 && !$text) stderr('Empty text for QueryLogObject', true); 30 31 $this->LogObject($connectionId, $user, $db, $text, $ignored); 32 } 33 34 function getEventType() { 35 return EVENT_QUERY; 36 } 37 38 function addSubQuery(& $queryLogObject) { 39 $this->subQueries[] =& $queryLogObject; 40 } 41 42 function & getSubQueries() { 43 return $this->subQueries; 44 } 45 46 function appendContext($context) { 47 if(!empty($this->subQueries)) { 48 $subQuery =& last($this->subQueries); 49 $subQuery->setContext($context); 50 } else { 51 $this->setContext($context); 52 } 53 } 54 55 function isSelect() { 56 return $this->check('select'); 57 } 58 59 function isDelete() { 60 return $this->check('delete'); 61 } 62 63 function isInsert() { 64 return $this->check('insert'); 65 } 66 67 function isUpdate() { 68 return $this->check('update'); 69 } 70 71 function check($start) { 72 $queryStart = strtolower(substr(trim($this->text), 0, 10)); 73 return (strpos($queryStart, $start) === 0); 74 } 75 76 function isIgnored() { 77 return (parent::isIgnored() || (CONFIG_ONLY_SELECT && !$this->isSelect())); 78 } 79 80 function setDuration($duration) { 81 $this->duration = $duration; 82 } 83 84 function getDuration() { 85 return $this->duration; 86 } 87} 88 89?>