29 | | function DBQuery() |
30 | | { |
31 | | $this->executed_ = false; |
32 | | $this->dbconn_ = new DBConnection; |
33 | | } |
34 | | |
35 | | function execute($sql) |
36 | | { |
37 | | $t1 = strtok(microtime(), ' ') + strtok(''); |
38 | | |
39 | | $this->resid_ = mysql_query($sql, $this->dbconn_->id()); |
40 | | |
41 | | if ($this->resid_ == false) |
42 | | { |
43 | | if (defined('DB_HALTONERROR') && DB_HALTONERROR) |
44 | | { |
45 | | echo "Database error: " . mysql_error($this->dbconn_->id()) . "<br>"; |
46 | | echo "SQL: " . $sql . "<br>"; |
47 | | exit; |
48 | | } |
49 | | else |
50 | | { |
51 | | return false; |
52 | | } |
53 | | } |
54 | | |
55 | | $this->exectime_ = strtok(microtime(), ' ') + strtok('') - $t1; |
56 | | $this->executed_ = true; |
57 | | |
58 | | if (KB_PROFILE == 2) |
59 | | { |
60 | | file_put_contents('/tmp/profile.lst', $sql . "\nExecution time: " . $this->exectime_ . "\n", FILE_APPEND); |
61 | | } |
62 | | |
63 | | return true; |
64 | | } |
65 | | |
66 | | function recordCount() |
67 | | { |
68 | | return mysql_num_rows($this->resid_); |
69 | | } |
70 | | |
71 | | function getRow() |
72 | | { |
73 | | if ($this->resid_) |
74 | | { |
75 | | return mysql_fetch_assoc($this->resid_); |
76 | | } |
77 | | return false; |
78 | | } |
79 | | |
80 | | function rewind() |
81 | | { |
82 | | @mysql_data_seek($this->resid_, 0); |
83 | | } |
84 | | |
85 | | function getInsertID() |
86 | | { |
87 | | return mysql_insert_id(); |
88 | | } |
89 | | |
90 | | function execTime() |
91 | | { |
92 | | return $this->exectime_; |
93 | | } |
94 | | |
95 | | function executed() |
96 | | { |
97 | | return $this->executed_; |
98 | | } |
99 | | |
100 | | function getErrorMsg() |
101 | | { |
102 | | $msg = $this->sql_ . "<br>"; |
103 | | $msg .= "Query failed. " . mysql_error($this->dbconn_->id()); |
104 | | |
105 | | return $msg; |
106 | | } |
| 12 | require_once('class.db.php'); |