Changeset 633 for trunk/inc/realm.php
- Timestamp:
- Sep 12, 2009, 10:50:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/realm.php
r630 r633 10 10 $this->Id = $Id; 11 11 $this->Database = new Database($this->Config['Mangos']['RealmList'][$Id]['DatabaseHost'], $this->Config['Mangos']['RealmList'][$Id]['DatabaseUser'], $this->Config['Mangos']['RealmList'][$Id]['DatabasePassword'], $this->Config['Mangos']['RealmList'][$Id]['DatabaseCharacters']); 12 if( mysqli_connect_error())12 if($this->Database->connect_error) 13 13 { 14 die('Přihlášení k databázi realmu '.$this->Id.' selhalo'); //: '.mysqli_connect_error());14 //die('Přihlášení k databázi realmu '.$this->Id.' selhalo: '.$this->Database->connect_error); 15 15 } 16 16 $this->Database->charset($this->Config['Database']['Charset']); … … 19 19 function OnlineCharactersCount() 20 20 { 21 $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']); 22 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `characters` WHERE `online` = 1'); 23 $DbRow = $DbResult->fetch_row(); 24 return($DbRow[0]); 21 if($this->Database->connect_error) return(0); 22 else { 23 $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']); 24 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `characters` WHERE `online` = 1'); 25 $DbRow = $DbResult->fetch_row(); 26 return($DbRow[0]); 27 } 25 28 } 26 29 … … 42 45 public function CharacterCount() 43 46 { 44 $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']); 45 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `characters`'); 46 $DbRow = $DbResult->fetch_row(); 47 return($DbRow[0]); 47 if($this->Database->connect_error) return(''); 48 else { 49 $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']); 50 $DbResult = $this->Database->query('SELECT COUNT(*) FROM `characters`'); 51 $DbRow = $DbResult->fetch_row(); 52 return($DbRow[0]); 53 } 48 54 } 49 55 50 56 public function GuidToCharName($guid) 51 57 { 52 $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']); 53 $row = $this->Database->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_array(); 54 return($row['name']); 58 if($this->Database->connect_error) return(0); 59 else { 60 $this->Database->select_db($this->Config['Mangos']['RealmList'][$this->Id]['DatabaseCharacters']); 61 $row = $this->Database->query('SELECT `name` FROM `characters` WHERE `guid` = "'.$guid.'" LIMIT 1')->fetch_array(); 62 return($row['name']); 63 } 55 64 } 56 65
Note:
See TracChangeset
for help on using the changeset viewer.