1 | <? |
---|
2 | require_once( "db.php" ); |
---|
3 | |
---|
4 | class SolarSystem { |
---|
5 | |
---|
6 | function SolarSystem( $id = 0 ) |
---|
7 | { |
---|
8 | $this->id_ = $id; |
---|
9 | $this->qry_ = new DBQuery(); |
---|
10 | |
---|
11 | $this->sql_ = "select * |
---|
12 | from kb3_systems sys, kb3_constellations con, |
---|
13 | kb3_regions reg |
---|
14 | where sys.sys_id = ".$this->id_." |
---|
15 | and con.con_id = sys.sys_con_id |
---|
16 | and reg.reg_id = con.con_reg_id"; |
---|
17 | } |
---|
18 | |
---|
19 | function getID() |
---|
20 | { |
---|
21 | return $this->id_; |
---|
22 | } |
---|
23 | |
---|
24 | function getName() |
---|
25 | { |
---|
26 | $this->execQuery(); |
---|
27 | return $this->row_['sys_name']; |
---|
28 | } |
---|
29 | |
---|
30 | function getSecurity( $rounded = false ) |
---|
31 | { |
---|
32 | $this->execQuery(); |
---|
33 | $sec = $this->row_['sys_sec']; |
---|
34 | |
---|
35 | if ( $rounded ) { |
---|
36 | if ( $sec <= 0 ) |
---|
37 | return number_format( 0.0, 1 ); |
---|
38 | else |
---|
39 | return number_format( round( $sec, 1 ), 1 ); |
---|
40 | } else return $sec; |
---|
41 | } |
---|
42 | |
---|
43 | function getConstellationName() |
---|
44 | { |
---|
45 | $this->execQuery(); |
---|
46 | return $this->row_['con_name']; |
---|
47 | } |
---|
48 | |
---|
49 | function getRegionName() |
---|
50 | { |
---|
51 | $this->execQuery(); |
---|
52 | return $this->row_['reg_name']; |
---|
53 | } |
---|
54 | |
---|
55 | function execQuery() |
---|
56 | { |
---|
57 | if ( !$this->qry_->executed_ ) { |
---|
58 | $this->qry_->execute( $this->sql_ ); |
---|
59 | $this->row_ = $this->qry_->getRow(); |
---|
60 | } |
---|
61 | } |
---|
62 | |
---|
63 | function lookup( $name ) |
---|
64 | { |
---|
65 | $qry = new DBQuery(); |
---|
66 | $qry->execute( "select * |
---|
67 | from kb3_systems |
---|
68 | where sys_name = '".slashfix( $name )."'" ); |
---|
69 | |
---|
70 | $row = $qry->getRow(); |
---|
71 | $this->id_ = $row['sys_id']; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | class Region |
---|
76 | { |
---|
77 | function Region( $id = 0 ) |
---|
78 | { |
---|
79 | $this->id_ = $id; |
---|
80 | } |
---|
81 | |
---|
82 | function getID() |
---|
83 | { |
---|
84 | return $this->id_; |
---|
85 | } |
---|
86 | |
---|
87 | function getName() |
---|
88 | { |
---|
89 | $this->execQuery(); |
---|
90 | return $this->row_['reg_name']; |
---|
91 | } |
---|
92 | |
---|
93 | function execQuery() |
---|
94 | { |
---|
95 | if ( !$this->qry_ ) { |
---|
96 | $this->qry_ = new DBQuery(); |
---|
97 | $this->qry_->execute( "select * from kb3_regions |
---|
98 | where reg_id = ".$this->id_ ); |
---|
99 | $this->row_ = $this->qry_->getRow(); |
---|
100 | } |
---|
101 | } |
---|
102 | } |
---|
103 | ?> |
---|