Changeset 951 for trunk/Packages
- Timestamp:
- Jul 12, 2023, 9:02:24 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Database.php
r929 r951 43 43 public bool $ShowSQLQuery; 44 44 public bool $LogSQLQuery; 45 public bool $MeasureDuration; 45 46 public string $LogFile; 46 47 public string $Database; … … 56 57 $this->ShowSQLQuery = false; 57 58 $this->LogSQLQuery = false; 59 $this->MeasureDuration = false; 58 60 $this->LogFile = dirname(__FILE__).'/../../Query.log'; 59 61 $this->Database = ''; … … 93 95 { 94 96 if (!$this->Connected()) throw new Exception(T('Not connected to database')); 95 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float(); 97 $Duration = ''; 98 if ($this->MeasureDuration) 99 { 100 $QueryStartTime = microtime_float(); 101 } 96 102 $this->LastQuery = $Query; 97 if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))98 {99 $Time = round(microtime_float() - $QueryStartTime, 4);100 $Duration = ' ; '.$Time. ' s';101 }102 if (($this->LogSQLQuery == true) and ($Time != 0))103 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);104 if ($this->ShowSQLQuery == true)105 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '.106 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n");107 103 $Result = new DatabaseResult(); 108 104 $Statement = $this->PDO->query($Query); … … 119 115 echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>'); 120 116 throw new Exception('SQL Error: '.$this->Error.', Query: '.$Query); 117 } 118 if ($this->MeasureDuration) 119 { 120 $Time = round(microtime_float() - $QueryStartTime, 4); 121 $Duration = ' ; '.$Time. ' s'; 122 } 123 if ($this->ShowSQLQuery == true) 124 { 125 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; '. 126 'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n"); 127 } 128 if ($this->LogSQLQuery == true) 129 { 130 file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND); 121 131 } 122 132 return $Result;
Note:
See TracChangeset
for help on using the changeset viewer.