Server Characters Model
The server characters model is an essential model for connecting to the characters database of the server. On this page, you can find documentation of the available functions of this model.
connect
$this->server_characters_model->connect() — Connect to characters DB
$this->server_characters_model->connect($realm): object
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
Return Values
Return an object to connect to character database.
Examples
$characters = $this->server_characters_model->connect(1);
// Returns the number of characters whose race is human
$count = $characters->from('characters')
    ->where('race', 1)
    ->count_all_results();
character
$this->server_characters_model->character() — Get character
$this->server_characters_model->character($realm, $guid): mixed
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $guid | int | Guid id | 
Return Values
Returns an object with all the data of the character or null if not exist.
Examples
$character = $this->server_characters_model->character(1, 1);
character_guid
$this->server_characters_model->character_guid() — Get character guid
$this->server_characters_model->character_guid($realm, $name): mixed
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $name | string | Character name | 
Return Values
Returns the guid of the character or null if not exist.
Examples
$guid = $this->server_characters_model->character_guid(1, 'Naeri');
character_name
$this->server_characters_model->character_name() — Get character name
$this->server_characters_model->character_name($realm, $guid): mixed
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $guid | int | Guid id | 
Return Values
Returns the name of the character or null if not exist.
Examples
$name = $this->server_characters_model->character_name(1, 1);
character_class
$this->server_characters_model->character_class() — Get character class
$this->server_characters_model->character_class($realm, $guid): mixed
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $guid | int | Guid id | 
Return Values
Returns the class of the character or null if not exist.
Examples
$class = $this->server_characters_model->character_class(1, 1);
character_race
$this->server_characters_model->character_race() — Get character race
$this->server_characters_model->character_race($realm, $guid): mixed
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $guid | int | Guid id | 
Return Values
Returns the race of the character or null if not exist.
Examples
$race = $this->server_characters_model->character_race(1, 1);
character_money
$this->server_characters_model->character_money() — Get character money
$this->server_characters_model->character_money($realm, $guid): mixed
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $guid | int | Guid id | 
Return Values
Returns the amount of money that the character has or null if not exist.
Examples
$money = $this->server_characters_model->character_money(1, 1);
character_exists
$this->server_characters_model->character_exists() — Check if the character exists
$this->server_characters_model->character_exists($realm, $guid): bool
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $guid | int | Guid id | 
Return Values
Returns true if the character exists or false on failure.
Examples
if ($this->server_characters_model->character_exists(1, 1)) {
    echo 'In the realm 1, the character with guid 1 exists';
}
character_linked
$this->server_characters_model->character_linked() — Check if the character is linked to the account
$this->server_characters_model->character_linked($realm, $guid, $account): bool
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $guid | int | Guid id | 
| $account | int | Account id | 
Return Values
Returns true if the character is linked to the account or false on failure.
Examples
if ($this->server_characters_model->character_linked(1, 1, 1)) {
    echo 'In the realm 1, the character with guid 1 is linked to account 1';
}
characters_online
$this->server_characters_model->characters_online() — Count characters online
$this->server_characters_model->characters_online($realm, $faction = null): int
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $faction | string|null | Faction type | 
Faction types:
alliancehordenull(both)
Return Values
Return the number of characters online depending on the faction.
Examples
$online = $this->server_characters_model->characters_online(1, 'horde');
all_characters
$this->server_characters_model->all_characters() — Get all account characters
$this->server_characters_model->all_characters($realm, $account): array
Parameters
| Parameter | Type | Description | 
|---|---|---|
| $realm | int | Realm id | 
| $account | int | Account id | 
Return Values
Returns an array with all the characters of an account in a realm.
Examples
$characters = $this->server_characters_model->all_characters(1, 1);