1 | <?php |
---|
2 | |
---|
3 | defined('SYSPATH') or die('No direct script access.'); |
---|
4 | |
---|
5 | class Killboard_Faction_Model extends Model |
---|
6 | { |
---|
7 | |
---|
8 | public $id = -1; |
---|
9 | public $name = ""; |
---|
10 | public $killCount = 0; |
---|
11 | public $lossCount = 0; |
---|
12 | public $finalBlows = 0; |
---|
13 | public $damageDone = 0; |
---|
14 | public $damageReceived = 0; |
---|
15 | public $efficiency = 0; |
---|
16 | public $corpCount = 0; |
---|
17 | public $pilotCount = 0; |
---|
18 | |
---|
19 | public function __construct($id=0, $name="", $killCount=0, $lossCount=0, |
---|
20 | $finalBlows=0,$damageDone=0,$damageReceived=0,$efficiency=0,$corps=0,$pilots=0) |
---|
21 | { |
---|
22 | parent::__construct(); |
---|
23 | |
---|
24 | if ($id==0) return; |
---|
25 | |
---|
26 | if (!is_numeric($id)) |
---|
27 | { |
---|
28 | // Faction name provided, check for existance and load SQL |
---|
29 | $db = Database::instance(); |
---|
30 | $query = $db->from('killboard_factions')->where('faction_name="'.$name.'"')->get(); |
---|
31 | if ($query->count() > 0) |
---|
32 | { |
---|
33 | $row = $query->current(); |
---|
34 | $this->id = $row->faction_id; |
---|
35 | $this->name = $row->faction_name; |
---|
36 | $this->killCount = $row->faction_kills; |
---|
37 | $this->finalBlows = $row->faction_final_blows; |
---|
38 | $this->lossCount = $row->faction_losses; |
---|
39 | $this->damageDone = $row->faction_damage_done; |
---|
40 | $this->damageReceived = $row->faction_damage_received; |
---|
41 | $this->pilotCount = $row->faction_pilots; |
---|
42 | $this->efficiency = $row->faction_efficiency; |
---|
43 | } |
---|
44 | } else { |
---|
45 | // Full/partial object data provided, load that sucka up |
---|
46 | if ($name == "") |
---|
47 | { |
---|
48 | // Only ID provided, load based on ID |
---|
49 | } else { |
---|
50 | // All data provided |
---|
51 | } |
---|
52 | } |
---|
53 | } |
---|
54 | |
---|
55 | } |
---|
56 | |
---|
57 | ?> |
---|