Changeset 498
- Timestamp:
- Mar 15, 2009, 9:07:39 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/pages/database.php
r497 r498 1 <<<<<<< .mine 2 <?php 3 4 // Extended database class 5 // Date: 2007-07-19 6 7 class Database extends mysqli 8 { 9 var $Prefix = ''; 10 11 function select($Table, $What = '*', $Condition = 1) 12 { 13 $Query = "SELECT ".$What." FROM `".$this->Prefix.$Table."` WHERE ".$Condition; 14 return($this->query($Query)); 15 } 16 17 function delete($Table, $Condition) 18 { 19 $this->query("DELETE FROM `".$this->Prefix.$Table."` WHERE ".$Condition); 20 } 21 22 function insert($Table, $Data) 23 { 24 $Name = ''; 25 $Values = ''; 26 foreach($Data as $Key => $Value) 27 { 28 $Value = strtr($Value, '"', '\"'); 29 $Name .= ','.$Key; 30 if($Value == 'NOW()') $Values .= ",".$Value; 31 else $Values .= ",'".$Value."'"; 32 } 33 $Name = substr($Name, 1); 34 $Values = substr($Values, 1); 35 $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')'); 36 } 37 38 function update($Table, $Condition, $Data) 39 { 40 $Values = ''; 41 foreach($Data as $Key => $Value) 42 { 43 $Value = strtr($Value, '"', '\"'); 44 if($Value != 'NOW()') $Value = "'".$Value."'"; 45 $Values .= ", ".$Key."=".$Value; 46 } 47 $Values = substr($Values, 2); 48 $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')'); 49 } 50 function replace($Table, $Data) 51 { 52 $Name = ''; 53 $Values = ''; 54 foreach($Data as $Key => $Value) 55 { 56 $Value = strtr($Value, '"', '\"'); 57 $Name .= ",".$Key; 58 if($Value == 'NOW()') $Values .= ",".$Value; 59 else $Values .= ',"'.$Value.'"'; 60 } 61 $Name = substr($Name, 1); 62 $Values = substr($Values, 1); 63 $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` (`'.$Name.'`) VALUES('.$values.')'); 64 } 65 66 function charset($Charset) 67 { 68 $this->query('SET CHARACTER SET '.$Charset); 69 } 70 71 } 72 73 ?> 74 ======= 1 75 <?php 2 76 … … 71 145 72 146 ?> 147 >>>>>>> .r497
Note:
See TracChangeset
for help on using the changeset viewer.