Changeset 153 for www/database.php
- Timestamp:
- Feb 16, 2009, 6:16:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
www/database.php
r148 r153 2 2 3 3 // Extended database class 4 // Date: 200 7-07-194 // Date: 2009-02-16 5 5 6 6 class Database extends mysqli 7 7 { 8 8 var $Prefix = ''; 9 var $LastQuery = '';10 9 11 10 function query($Query) 12 11 { 13 $this->LastQuery = $Query; 14 return(parent::query($Query)); 12 global $Config; 13 14 if($Config['Web']['ShowSQLQuery'] == true) 15 echo('<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.'</div>'); 16 $Result = parent::query($Query); 17 if(($this->error != '') and ($Config['Web']['ShowSQLError'] == true)) 18 echo('<div><strong>SQL Error: </strong>'.$this->error.'<br>'.$Query.'</div>'); 19 20 return($Result); 15 21 } 16 22 17 23 function select($Table, $What = '*', $Condition = 1) 18 24 { 19 $this->LastQuery = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition; 20 return($this->query($this->LastQuery)); 25 return($this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition)); 21 26 } 22 27 23 28 function delete($Table, $Condition) 24 29 { 25 $this->LastQuery = "DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition; 26 $this->query($this->LastQuery); 30 $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition); 27 31 } 28 32 … … 41 45 $Name = substr($Name, 1); 42 46 $Values = substr($Values, 1); 43 $this->LastQuery = 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'; 44 $this->query($this->LastQuery); 47 $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 45 48 } 46 49 … … 55 58 } 56 59 $Values = substr($Values, 2); 57 $this->LastQuery = 'UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'; 58 $this->query($this->LastQuery); 60 $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'); 59 61 } 60 62 … … 73 75 $Values = substr($Values, 1); 74 76 //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br>'); 75 $this->LastQuery = 'REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'; 76 $this->query($this->LastQuery); 77 $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 77 78 //echo($this->error().'<br>'); 78 79 } … … 80 81 function charset($Charset) 81 82 { 82 $this->LastQuery = "SET NAMES '".$Charset."'"; 83 $this->query($this->LastQuery); 83 $this->query('SET NAMES "'.$Charset.'"'); 84 84 } 85 85
Note:
See TracChangeset
for help on using the changeset viewer.