Changeset 13 for database.php
- Timestamp:
- Oct 13, 2008, 1:56:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
database.php
r9 r13 2 2 3 3 // Extended database class 4 // Date: 200 7-07-194 // Date: 2008-10-13 5 5 6 6 class Database extends mysqli … … 8 8 var $Prefix = ''; 9 9 var $LastQuery = ''; 10 10 var $ShowError = 0; 11 11 12 function query($Query) 12 13 { 13 14 $this->LastQuery = $Query; 14 return(parent::query($Query)); 15 $DbResult = parent::query($Query); 16 if(($this->ShowError == TRUE) and ($this->error != '')) 17 { 18 echo('<strong>Database error:</strong> '.$this->error.'<br /><strong>Query:</strong> '.$Query.'<br />'); 19 //echo('<pre>'); print_r(debug_backtrace()); echo('</pre>'); 20 } 21 return($DbResult); 15 22 } 16 23 17 24 function select($Table, $What = '*', $Condition = 1) 18 25 { 19 $this->LastQuery = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition; 20 return($this->query($this->LastQuery)); 26 return($this->query("SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition)); 21 27 } 22 28 23 29 function delete($Table, $Condition) 24 30 { 25 $this->LastQuery = "DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition; 26 $this->query($this->LastQuery); 31 $this->query("DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition); 27 32 } 28 33 29 34 function insert($Table, $Data) 30 35 { … … 35 40 $Value = strtr($Value, '"', '\"'); 36 41 $Name .= ',`'.$Key.'`'; 37 38 42 if($Value == 'NOW()') $Values .= ",".$Value; 43 else $Values .= ",'".$Value."'"; 39 44 } 40 45 $Name = substr($Name, 1); 41 46 $Values = substr($Values, 1); 42 $this->LastQuery = 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'; 43 $this->query($this->LastQuery); 47 $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 44 48 } 45 49 46 50 function update($Table, $Condition, $Data) 47 51 { … … 49 53 foreach($Data as $Key => $Value) 50 54 { 51 55 $Value = strtr($Value, '"', '\"'); 52 56 if($Value != 'NOW()') $Value = "'".$Value."'"; 53 57 $Values .= ", ".$Key."=".$Value; 54 58 } 55 $Values = substr($Values, 2); 56 $this->LastQuery = 'UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'; 57 $this->query($this->LastQuery); 59 $Values = substr($Values, 2); 60 $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'); 58 61 } 59 62 60 63 function replace($Table, $Data) 61 64 { … … 72 75 $Values = substr($Values, 1); 73 76 //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br>'); 74 $this->LastQuery = 'REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'; 75 $this->query($this->LastQuery); 76 //echo($this->error().'<br>'); 77 $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 77 78 } 78 79 79 80 function charset($Charset) 80 81 { 81 $this->LastQuery = 'SET CHARACTER SET '.$Charset; 82 $this->query($this->LastQuery); 82 $this->query('SET CHARACTER SET '.$Charset); 83 83 } 84 84
Note:
See TracChangeset
for help on using the changeset viewer.