Changeset 30 for database.php
- Timestamp:
- Dec 16, 2008, 8:15:34 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
database.php
r24 r30 2 2 3 3 // Extended database class 4 // Date: 2008-1 0-134 // Date: 2008-12-15 5 5 6 6 class Database extends mysqli … … 16 16 if(($this->ShowError == TRUE) and ($this->error != '')) 17 17 { 18 echo('<strong>Database error:</strong> '.$this->error.'<br /><strong>Query:</strong> '.$Query.'<br />'); 18 echo('<strong>Database error:</strong> '.$this->error.'<br />'); 19 echo('<strong>Query:</strong> '.$Query.'<br />'); 19 20 echo('<pre style="font-size: 9px">'); print_r(debug_backtrace()); echo('</pre>'); 20 21 } … … 22 23 } 23 24 24 function select($ Table, $What = '*', $Condition = 1)25 function select($Parameters) // Database, Table, Columns, Condition, Order 25 26 { 26 return($this->query("SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition)); 27 $Query = 'SELECT '; 28 if(array_key_exists('Columns', $Parameters)) $Query .= $Parameters['Columns']; else $Query .= '*'; 29 $Query .= ' FROM '; 30 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 31 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 32 if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition']; 33 return($this->query($Query)); 27 34 } 28 35 29 function delete($ Table, $Condition)36 function delete($Parameters) 30 37 { 31 $this->query("DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition); 38 $Query = 'DELETE FROM '; 39 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 40 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 41 if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition']; 42 $this->query($Query); 32 43 } 33 44 34 function insert($ Table, $Data)45 function insert($Parameters, $Data) 35 46 { 36 47 $Name = ''; … … 45 56 $Name = substr($Name, 1); 46 57 $Values = substr($Values, 1); 47 $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 58 $Query = 'INSERT INTO '; 59 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 60 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 61 $Query .= ' ('.$Name.') VALUES ('.$Values.')'; 62 $this->query($Query); 48 63 } 49 64 50 function update($ Table, $Condition, $Data)65 function update($Parameters, $Data) 51 66 { 52 67 $Values = ''; … … 58 73 } 59 74 $Values = substr($Values, 2); 60 $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'); 75 $Query = 'UPDATE '; 76 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 77 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 78 $Query .= ' SET '.$Values; 79 if(array_key_exists('Condition', $Parameters)) $Query .= ' WHERE '.$Parameters['Condition']; 80 $this->query($Query); 61 81 } 62 82 63 function replace($ Table, $Data)83 function replace($Parameters, $Data) 64 84 { 65 85 $Name = ''; … … 75 95 $Values = substr($Values, 1); 76 96 //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br>'); 77 $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 97 $Query = 'REPLACE INTO '; 98 if(array_key_exists('Database', $Parameters) and ($Parameters['Database'] != '')) $Query .= '`'.$Parameters['Database'].'`.'; 99 $Query .= '`'.$this->Prefix.$Parameters['Table'].'`'; 100 $Query .= ' ('.$Name.') VALUES ('.$Values.')'; 101 $this->query($Query); 78 102 } 79 103
Note:
See TracChangeset
for help on using the changeset viewer.