Revision 133, 2.1 KB
(checked in by exi, 16 years ago)
|
Reduced one potential sql-bug.
Added ability to identify items as t2 via their techlevel rather than just 'II'.
Fixed item location 0 to not cause skipping that item.
Added anzahl/quantity-replace for the german killpreparser.
Fixed final blow award to show correct numbers.
Removed unnecessary code from db.php.
Added a table data check to the sql importer and made the importer more verbose, this should minimize support requests caused by empty table data.
Fixed a small misalignment of the comment block.
|
Line | |
---|
1 | <?php |
---|
2 | require_once('config.php'); |
---|
3 | require_once('globals.php'); |
---|
4 | |
---|
5 | class DBConnection |
---|
6 | { |
---|
7 | function DBConnection() |
---|
8 | { |
---|
9 | if (!$this->id_ = mysql_pconnect(DB_HOST, DB_USER, DB_PASS)) |
---|
10 | die("Unable to connect to mysql database."); |
---|
11 | |
---|
12 | mysql_select_db(DB_NAME); |
---|
13 | } |
---|
14 | |
---|
15 | function id() |
---|
16 | { |
---|
17 | return $this->id_; |
---|
18 | } |
---|
19 | |
---|
20 | function affectedRows() |
---|
21 | { |
---|
22 | return mysql_affected_rows($this->id_); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | class DBQuery |
---|
27 | { |
---|
28 | function DBQuery() |
---|
29 | { |
---|
30 | $this->executed_ = false; |
---|
31 | $this->dbconn_ = new DBConnection; |
---|
32 | } |
---|
33 | |
---|
34 | function execute($sql) |
---|
35 | { |
---|
36 | $t1 = strtok(microtime(), ' ') + strtok(''); |
---|
37 | |
---|
38 | $this->resid_ = mysql_query($sql, $this->dbconn_->id()); |
---|
39 | |
---|
40 | if (!$this->resid_) |
---|
41 | { |
---|
42 | if (defined(DB_HALTONERROR) && DB_HALTONERROR) |
---|
43 | { |
---|
44 | echo "Database error: " . mysql_error($this->dbconn_->id()) . "<br>"; |
---|
45 | echo "SQL: " . $sql . "<br>"; |
---|
46 | exit; |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | return false; |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | $this->exectime_ = strtok(microtime(), ' ') + strtok('') - $t1; |
---|
55 | $this->executed_ = true; |
---|
56 | |
---|
57 | if (KB_PROFILE == 2) |
---|
58 | { |
---|
59 | file_put_contents('/tmp/profile.lst', $sql . "\nExecution time: " . $this->exectime_ . "\n", FILE_APPEND); |
---|
60 | } |
---|
61 | |
---|
62 | return true; |
---|
63 | } |
---|
64 | |
---|
65 | function recordCount() |
---|
66 | { |
---|
67 | return mysql_num_rows($this->resid_); |
---|
68 | } |
---|
69 | |
---|
70 | function getRow() |
---|
71 | { |
---|
72 | if ($this->resid_) |
---|
73 | { |
---|
74 | return mysql_fetch_assoc($this->resid_); |
---|
75 | } |
---|
76 | return false; |
---|
77 | } |
---|
78 | |
---|
79 | function rewind() |
---|
80 | { |
---|
81 | @mysql_data_seek($this->resid_, 0); |
---|
82 | } |
---|
83 | |
---|
84 | function getInsertID() |
---|
85 | { |
---|
86 | return mysql_insert_id(); |
---|
87 | } |
---|
88 | |
---|
89 | function execTime() |
---|
90 | { |
---|
91 | return $this->exectime_; |
---|
92 | } |
---|
93 | |
---|
94 | function executed() |
---|
95 | { |
---|
96 | return $this->executed_; |
---|
97 | } |
---|
98 | |
---|
99 | function getErrorMsg() |
---|
100 | { |
---|
101 | $msg = $this->sql_ . "<br>"; |
---|
102 | $msg .= "Query failed. " . mysql_error($this->dbconn_->id()); |
---|
103 | |
---|
104 | return $msg; |
---|
105 | } |
---|
106 | } |
---|
107 | ?> |
---|