|
indvdum@0
|
1 |
<?php
|
|
indvdum@0
|
2 |
/**
|
|
indvdum@0
|
3 |
*
|
|
indvdum@0
|
4 |
* @package dbal
|
|
indvdum@0
|
5 |
* @version $Id$
|
|
indvdum@0
|
6 |
* @copyright (c) 2005 phpBB Group
|
|
indvdum@0
|
7 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
indvdum@0
|
8 |
*
|
|
indvdum@0
|
9 |
*/
|
|
indvdum@0
|
10 |
|
|
indvdum@0
|
11 |
/**
|
|
indvdum@0
|
12 |
* @ignore
|
|
indvdum@0
|
13 |
*/
|
|
indvdum@0
|
14 |
if (!defined('IN_PHPBB'))
|
|
indvdum@0
|
15 |
{
|
|
indvdum@0
|
16 |
exit;
|
|
indvdum@0
|
17 |
}
|
|
indvdum@0
|
18 |
|
|
indvdum@0
|
19 |
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
|
indvdum@0
|
20 |
|
|
indvdum@0
|
21 |
/**
|
|
indvdum@0
|
22 |
* Unified ODBC functions
|
|
indvdum@0
|
23 |
* Unified ODBC functions support any database having ODBC driver, for example Adabas D, IBM DB2, iODBC, Solid, Sybase SQL Anywhere...
|
|
indvdum@0
|
24 |
* Here we only support MSSQL Server 2000+ because of the provided schema
|
|
indvdum@0
|
25 |
*
|
|
indvdum@0
|
26 |
* @note number of bytes returned for returning data depends on odbc.defaultlrl php.ini setting.
|
|
indvdum@0
|
27 |
* If it is limited to 4K for example only 4K of data is returned max, resulting in incomplete theme data for example.
|
|
indvdum@0
|
28 |
* @note odbc.defaultbinmode may affect UTF8 characters
|
|
indvdum@0
|
29 |
*
|
|
indvdum@0
|
30 |
* @package dbal
|
|
indvdum@0
|
31 |
*/
|
|
indvdum@0
|
32 |
class dbal_mssql_odbc extends dbal
|
|
indvdum@0
|
33 |
{
|
|
indvdum@0
|
34 |
var $last_query_text = '';
|
|
indvdum@0
|
35 |
|
|
indvdum@0
|
36 |
/**
|
|
indvdum@0
|
37 |
* Connect to server
|
|
indvdum@0
|
38 |
*/
|
|
indvdum@0
|
39 |
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
|
|
indvdum@0
|
40 |
{
|
|
indvdum@0
|
41 |
$this->persistency = $persistency;
|
|
indvdum@0
|
42 |
$this->user = $sqluser;
|
|
indvdum@0
|
43 |
$this->dbname = $database;
|
|
indvdum@0
|
44 |
|
|
indvdum@0
|
45 |
$port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':';
|
|
indvdum@0
|
46 |
$this->server = $sqlserver . (($port) ? $port_delimiter . $port : '');
|
|
indvdum@0
|
47 |
|
|
indvdum@0
|
48 |
$max_size = @ini_get('odbc.defaultlrl');
|
|
indvdum@0
|
49 |
if (!empty($max_size))
|
|
indvdum@0
|
50 |
{
|
|
indvdum@0
|
51 |
$unit = strtolower(substr($max_size, -1, 1));
|
|
indvdum@0
|
52 |
$max_size = (int) $max_size;
|
|
indvdum@0
|
53 |
|
|
indvdum@0
|
54 |
if ($unit == 'k')
|
|
indvdum@0
|
55 |
{
|
|
indvdum@0
|
56 |
$max_size = floor($max_size / 1024);
|
|
indvdum@0
|
57 |
}
|
|
indvdum@0
|
58 |
else if ($unit == 'g')
|
|
indvdum@0
|
59 |
{
|
|
indvdum@0
|
60 |
$max_size *= 1024;
|
|
indvdum@0
|
61 |
}
|
|
indvdum@0
|
62 |
else if (is_numeric($unit))
|
|
indvdum@0
|
63 |
{
|
|
indvdum@0
|
64 |
$max_size = floor((int) ($max_size . $unit) / 1048576);
|
|
indvdum@0
|
65 |
}
|
|
indvdum@0
|
66 |
$max_size = max(8, $max_size) . 'M';
|
|
indvdum@0
|
67 |
|
|
indvdum@0
|
68 |
@ini_set('odbc.defaultlrl', $max_size);
|
|
indvdum@0
|
69 |
}
|
|
indvdum@0
|
70 |
|
|
indvdum@0
|
71 |
$this->db_connect_id = ($this->persistency) ? @odbc_pconnect($this->server, $this->user, $sqlpassword) : @odbc_connect($this->server, $this->user, $sqlpassword);
|
|
indvdum@0
|
72 |
|
|
indvdum@0
|
73 |
return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error('');
|
|
indvdum@0
|
74 |
}
|
|
indvdum@0
|
75 |
|
|
indvdum@0
|
76 |
/**
|
|
indvdum@0
|
77 |
* Version information about used database
|
|
indvdum@0
|
78 |
* @param bool $raw if true, only return the fetched sql_server_version
|
|
indvdum@0
|
79 |
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
|
indvdum@0
|
80 |
* @return string sql server version
|
|
indvdum@0
|
81 |
*/
|
|
indvdum@0
|
82 |
function sql_server_info($raw = false, $use_cache = true)
|
|
indvdum@0
|
83 |
{
|
|
indvdum@0
|
84 |
global $cache;
|
|
indvdum@0
|
85 |
|
|
indvdum@0
|
86 |
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false)
|
|
indvdum@0
|
87 |
{
|
|
indvdum@0
|
88 |
$result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')");
|
|
indvdum@0
|
89 |
|
|
indvdum@0
|
90 |
$row = false;
|
|
indvdum@0
|
91 |
if ($result_id)
|
|
indvdum@0
|
92 |
{
|
|
indvdum@0
|
93 |
$row = @odbc_fetch_array($result_id);
|
|
indvdum@0
|
94 |
@odbc_free_result($result_id);
|
|
indvdum@0
|
95 |
}
|
|
indvdum@0
|
96 |
|
|
indvdum@0
|
97 |
$this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0;
|
|
indvdum@0
|
98 |
|
|
indvdum@0
|
99 |
if (!empty($cache) && $use_cache)
|
|
indvdum@0
|
100 |
{
|
|
indvdum@0
|
101 |
$cache->put('mssqlodbc_version', $this->sql_server_version);
|
|
indvdum@0
|
102 |
}
|
|
indvdum@0
|
103 |
}
|
|
indvdum@0
|
104 |
|
|
indvdum@0
|
105 |
if ($raw)
|
|
indvdum@0
|
106 |
{
|
|
indvdum@0
|
107 |
return $this->sql_server_version;
|
|
indvdum@0
|
108 |
}
|
|
indvdum@0
|
109 |
|
|
indvdum@0
|
110 |
return ($this->sql_server_version) ? 'MSSQL (ODBC)<br />' . $this->sql_server_version : 'MSSQL (ODBC)';
|
|
indvdum@0
|
111 |
}
|
|
indvdum@0
|
112 |
|
|
indvdum@0
|
113 |
/**
|
|
indvdum@0
|
114 |
* SQL Transaction
|
|
indvdum@0
|
115 |
* @access private
|
|
indvdum@0
|
116 |
*/
|
|
indvdum@0
|
117 |
function _sql_transaction($status = 'begin')
|
|
indvdum@0
|
118 |
{
|
|
indvdum@0
|
119 |
switch ($status)
|
|
indvdum@0
|
120 |
{
|
|
indvdum@0
|
121 |
case 'begin':
|
|
indvdum@0
|
122 |
return @odbc_exec($this->db_connect_id, 'BEGIN TRANSACTION');
|
|
indvdum@0
|
123 |
break;
|
|
indvdum@0
|
124 |
|
|
indvdum@0
|
125 |
case 'commit':
|
|
indvdum@0
|
126 |
return @odbc_exec($this->db_connect_id, 'COMMIT TRANSACTION');
|
|
indvdum@0
|
127 |
break;
|
|
indvdum@0
|
128 |
|
|
indvdum@0
|
129 |
case 'rollback':
|
|
indvdum@0
|
130 |
return @odbc_exec($this->db_connect_id, 'ROLLBACK TRANSACTION');
|
|
indvdum@0
|
131 |
break;
|
|
indvdum@0
|
132 |
}
|
|
indvdum@0
|
133 |
|
|
indvdum@0
|
134 |
return true;
|
|
indvdum@0
|
135 |
}
|
|
indvdum@0
|
136 |
|
|
indvdum@0
|
137 |
/**
|
|
indvdum@0
|
138 |
* Base query method
|
|
indvdum@0
|
139 |
*
|
|
indvdum@0
|
140 |
* @param string $query Contains the SQL query which shall be executed
|
|
indvdum@0
|
141 |
* @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache
|
|
indvdum@0
|
142 |
* @return mixed When casted to bool the returned value returns true on success and false on failure
|
|
indvdum@0
|
143 |
*
|
|
indvdum@0
|
144 |
* @access public
|
|
indvdum@0
|
145 |
*/
|
|
indvdum@0
|
146 |
function sql_query($query = '', $cache_ttl = 0)
|
|
indvdum@0
|
147 |
{
|
|
indvdum@0
|
148 |
if ($query != '')
|
|
indvdum@0
|
149 |
{
|
|
indvdum@0
|
150 |
global $cache;
|
|
indvdum@0
|
151 |
|
|
indvdum@0
|
152 |
// EXPLAIN only in extra debug mode
|
|
indvdum@0
|
153 |
if (defined('DEBUG_EXTRA'))
|
|
indvdum@0
|
154 |
{
|
|
indvdum@0
|
155 |
$this->sql_report('start', $query);
|
|
indvdum@0
|
156 |
}
|
|
indvdum@0
|
157 |
|
|
indvdum@0
|
158 |
$this->last_query_text = $query;
|
|
indvdum@0
|
159 |
$this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
|
|
indvdum@0
|
160 |
$this->sql_add_num_queries($this->query_result);
|
|
indvdum@0
|
161 |
|
|
indvdum@0
|
162 |
if ($this->query_result === false)
|
|
indvdum@0
|
163 |
{
|
|
indvdum@0
|
164 |
if (($this->query_result = @odbc_exec($this->db_connect_id, $query)) === false)
|
|
indvdum@0
|
165 |
{
|
|
indvdum@0
|
166 |
$this->sql_error($query);
|
|
indvdum@0
|
167 |
}
|
|
indvdum@0
|
168 |
|
|
indvdum@0
|
169 |
if (defined('DEBUG_EXTRA'))
|
|
indvdum@0
|
170 |
{
|
|
indvdum@0
|
171 |
$this->sql_report('stop', $query);
|
|
indvdum@0
|
172 |
}
|
|
indvdum@0
|
173 |
|
|
indvdum@0
|
174 |
if ($cache_ttl && method_exists($cache, 'sql_save'))
|
|
indvdum@0
|
175 |
{
|
|
indvdum@0
|
176 |
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
|
indvdum@0
|
177 |
$cache->sql_save($query, $this->query_result, $cache_ttl);
|
|
indvdum@0
|
178 |
}
|
|
indvdum@0
|
179 |
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
|
|
indvdum@0
|
180 |
{
|
|
indvdum@0
|
181 |
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
|
indvdum@0
|
182 |
}
|
|
indvdum@0
|
183 |
}
|
|
indvdum@0
|
184 |
else if (defined('DEBUG_EXTRA'))
|
|
indvdum@0
|
185 |
{
|
|
indvdum@0
|
186 |
$this->sql_report('fromcache', $query);
|
|
indvdum@0
|
187 |
}
|
|
indvdum@0
|
188 |
}
|
|
indvdum@0
|
189 |
else
|
|
indvdum@0
|
190 |
{
|
|
indvdum@0
|
191 |
return false;
|
|
indvdum@0
|
192 |
}
|
|
indvdum@0
|
193 |
|
|
indvdum@0
|
194 |
return $this->query_result;
|
|
indvdum@0
|
195 |
}
|
|
indvdum@0
|
196 |
|
|
indvdum@0
|
197 |
/**
|
|
indvdum@0
|
198 |
* Build LIMIT query
|
|
indvdum@0
|
199 |
*/
|
|
indvdum@0
|
200 |
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
|
|
indvdum@0
|
201 |
{
|
|
indvdum@0
|
202 |
$this->query_result = false;
|
|
indvdum@0
|
203 |
|
|
indvdum@0
|
204 |
// Since TOP is only returning a set number of rows we won't need it if total is set to 0 (return all rows)
|
|
indvdum@0
|
205 |
if ($total)
|
|
indvdum@0
|
206 |
{
|
|
indvdum@0
|
207 |
// We need to grab the total number of rows + the offset number of rows to get the correct result
|
|
indvdum@0
|
208 |
if (strpos($query, 'SELECT DISTINCT') === 0)
|
|
indvdum@0
|
209 |
{
|
|
indvdum@0
|
210 |
$query = 'SELECT DISTINCT TOP ' . ($total + $offset) . ' ' . substr($query, 15);
|
|
indvdum@0
|
211 |
}
|
|
indvdum@0
|
212 |
else
|
|
indvdum@0
|
213 |
{
|
|
indvdum@0
|
214 |
$query = 'SELECT TOP ' . ($total + $offset) . ' ' . substr($query, 6);
|
|
indvdum@0
|
215 |
}
|
|
indvdum@0
|
216 |
}
|
|
indvdum@0
|
217 |
|
|
indvdum@0
|
218 |
$result = $this->sql_query($query, $cache_ttl);
|
|
indvdum@0
|
219 |
|
|
indvdum@0
|
220 |
// Seek by $offset rows
|
|
indvdum@0
|
221 |
if ($offset)
|
|
indvdum@0
|
222 |
{
|
|
indvdum@0
|
223 |
$this->sql_rowseek($offset, $result);
|
|
indvdum@0
|
224 |
}
|
|
indvdum@0
|
225 |
|
|
indvdum@0
|
226 |
return $result;
|
|
indvdum@0
|
227 |
}
|
|
indvdum@0
|
228 |
|
|
indvdum@0
|
229 |
/**
|
|
indvdum@0
|
230 |
* Return number of affected rows
|
|
indvdum@0
|
231 |
*/
|
|
indvdum@0
|
232 |
function sql_affectedrows()
|
|
indvdum@0
|
233 |
{
|
|
indvdum@0
|
234 |
return ($this->db_connect_id) ? @odbc_num_rows($this->query_result) : false;
|
|
indvdum@0
|
235 |
}
|
|
indvdum@0
|
236 |
|
|
indvdum@0
|
237 |
/**
|
|
indvdum@0
|
238 |
* Fetch current row
|
|
indvdum@0
|
239 |
* @note number of bytes returned depends on odbc.defaultlrl php.ini setting. If it is limited to 4K for example only 4K of data is returned max.
|
|
indvdum@0
|
240 |
*/
|
|
indvdum@0
|
241 |
function sql_fetchrow($query_id = false, $debug = false)
|
|
indvdum@0
|
242 |
{
|
|
indvdum@0
|
243 |
global $cache;
|
|
indvdum@0
|
244 |
|
|
indvdum@0
|
245 |
if ($query_id === false)
|
|
indvdum@0
|
246 |
{
|
|
indvdum@0
|
247 |
$query_id = $this->query_result;
|
|
indvdum@0
|
248 |
}
|
|
indvdum@0
|
249 |
|
|
indvdum@0
|
250 |
if (isset($cache->sql_rowset[$query_id]))
|
|
indvdum@0
|
251 |
{
|
|
indvdum@0
|
252 |
return $cache->sql_fetchrow($query_id);
|
|
indvdum@0
|
253 |
}
|
|
indvdum@0
|
254 |
|
|
indvdum@0
|
255 |
return ($query_id !== false) ? @odbc_fetch_array($query_id) : false;
|
|
indvdum@0
|
256 |
}
|
|
indvdum@0
|
257 |
|
|
indvdum@0
|
258 |
/**
|
|
indvdum@0
|
259 |
* Seek to given row number
|
|
indvdum@0
|
260 |
* rownum is zero-based
|
|
indvdum@0
|
261 |
*/
|
|
indvdum@0
|
262 |
function sql_rowseek($rownum, &$query_id)
|
|
indvdum@0
|
263 |
{
|
|
indvdum@0
|
264 |
global $cache;
|
|
indvdum@0
|
265 |
|
|
indvdum@0
|
266 |
if ($query_id === false)
|
|
indvdum@0
|
267 |
{
|
|
indvdum@0
|
268 |
$query_id = $this->query_result;
|
|
indvdum@0
|
269 |
}
|
|
indvdum@0
|
270 |
|
|
indvdum@0
|
271 |
if (isset($cache->sql_rowset[$query_id]))
|
|
indvdum@0
|
272 |
{
|
|
indvdum@0
|
273 |
return $cache->sql_rowseek($rownum, $query_id);
|
|
indvdum@0
|
274 |
}
|
|
indvdum@0
|
275 |
|
|
indvdum@0
|
276 |
if ($query_id === false)
|
|
indvdum@0
|
277 |
{
|
|
indvdum@0
|
278 |
return false;
|
|
indvdum@0
|
279 |
}
|
|
indvdum@0
|
280 |
|
|
indvdum@0
|
281 |
$this->sql_freeresult($query_id);
|
|
indvdum@0
|
282 |
$query_id = $this->sql_query($this->last_query_text);
|
|
indvdum@0
|
283 |
|
|
indvdum@0
|
284 |
if ($query_id === false)
|
|
indvdum@0
|
285 |
{
|
|
indvdum@0
|
286 |
return false;
|
|
indvdum@0
|
287 |
}
|
|
indvdum@0
|
288 |
|
|
indvdum@0
|
289 |
// We do not fetch the row for rownum == 0 because then the next resultset would be the second row
|
|
indvdum@0
|
290 |
for ($i = 0; $i < $rownum; $i++)
|
|
indvdum@0
|
291 |
{
|
|
indvdum@0
|
292 |
if (!$this->sql_fetchrow($query_id))
|
|
indvdum@0
|
293 |
{
|
|
indvdum@0
|
294 |
return false;
|
|
indvdum@0
|
295 |
}
|
|
indvdum@0
|
296 |
}
|
|
indvdum@0
|
297 |
|
|
indvdum@0
|
298 |
return true;
|
|
indvdum@0
|
299 |
}
|
|
indvdum@0
|
300 |
|
|
indvdum@0
|
301 |
/**
|
|
indvdum@0
|
302 |
* Get last inserted id after insert statement
|
|
indvdum@0
|
303 |
*/
|
|
indvdum@0
|
304 |
function sql_nextid()
|
|
indvdum@0
|
305 |
{
|
|
indvdum@0
|
306 |
$result_id = @odbc_exec($this->db_connect_id, 'SELECT @@IDENTITY');
|
|
indvdum@0
|
307 |
|
|
indvdum@0
|
308 |
if ($result_id)
|
|
indvdum@0
|
309 |
{
|
|
indvdum@0
|
310 |
if (@odbc_fetch_array($result_id))
|
|
indvdum@0
|
311 |
{
|
|
indvdum@0
|
312 |
$id = @odbc_result($result_id, 1);
|
|
indvdum@0
|
313 |
@odbc_free_result($result_id);
|
|
indvdum@0
|
314 |
return $id;
|
|
indvdum@0
|
315 |
}
|
|
indvdum@0
|
316 |
@odbc_free_result($result_id);
|
|
indvdum@0
|
317 |
}
|
|
indvdum@0
|
318 |
|
|
indvdum@0
|
319 |
return false;
|
|
indvdum@0
|
320 |
}
|
|
indvdum@0
|
321 |
|
|
indvdum@0
|
322 |
/**
|
|
indvdum@0
|
323 |
* Free sql result
|
|
indvdum@0
|
324 |
*/
|
|
indvdum@0
|
325 |
function sql_freeresult($query_id = false)
|
|
indvdum@0
|
326 |
{
|
|
indvdum@0
|
327 |
global $cache;
|
|
indvdum@0
|
328 |
|
|
indvdum@0
|
329 |
if ($query_id === false)
|
|
indvdum@0
|
330 |
{
|
|
indvdum@0
|
331 |
$query_id = $this->query_result;
|
|
indvdum@0
|
332 |
}
|
|
indvdum@0
|
333 |
|
|
indvdum@0
|
334 |
if (isset($cache->sql_rowset[$query_id]))
|
|
indvdum@0
|
335 |
{
|
|
indvdum@0
|
336 |
return $cache->sql_freeresult($query_id);
|
|
indvdum@0
|
337 |
}
|
|
indvdum@0
|
338 |
|
|
indvdum@0
|
339 |
if (isset($this->open_queries[(int) $query_id]))
|
|
indvdum@0
|
340 |
{
|
|
indvdum@0
|
341 |
unset($this->open_queries[(int) $query_id]);
|
|
indvdum@0
|
342 |
return @odbc_free_result($query_id);
|
|
indvdum@0
|
343 |
}
|
|
indvdum@0
|
344 |
|
|
indvdum@0
|
345 |
return false;
|
|
indvdum@0
|
346 |
}
|
|
indvdum@0
|
347 |
|
|
indvdum@0
|
348 |
/**
|
|
indvdum@0
|
349 |
* Escape string used in sql query
|
|
indvdum@0
|
350 |
*/
|
|
indvdum@0
|
351 |
function sql_escape($msg)
|
|
indvdum@0
|
352 |
{
|
|
indvdum@0
|
353 |
return str_replace(array("'", "\0"), array("''", ''), $msg);
|
|
indvdum@0
|
354 |
}
|
|
indvdum@0
|
355 |
|
|
indvdum@0
|
356 |
/**
|
|
indvdum@0
|
357 |
* Build LIKE expression
|
|
indvdum@0
|
358 |
* @access private
|
|
indvdum@0
|
359 |
*/
|
|
indvdum@0
|
360 |
function _sql_like_expression($expression)
|
|
indvdum@0
|
361 |
{
|
|
indvdum@0
|
362 |
return $expression . " ESCAPE '\\'";
|
|
indvdum@0
|
363 |
}
|
|
indvdum@0
|
364 |
|
|
indvdum@0
|
365 |
/**
|
|
indvdum@0
|
366 |
* Build db-specific query data
|
|
indvdum@0
|
367 |
* @access private
|
|
indvdum@0
|
368 |
*/
|
|
indvdum@0
|
369 |
function _sql_custom_build($stage, $data)
|
|
indvdum@0
|
370 |
{
|
|
indvdum@0
|
371 |
return $data;
|
|
indvdum@0
|
372 |
}
|
|
indvdum@0
|
373 |
|
|
indvdum@0
|
374 |
/**
|
|
indvdum@0
|
375 |
* return sql error array
|
|
indvdum@0
|
376 |
* @access private
|
|
indvdum@0
|
377 |
*/
|
|
indvdum@0
|
378 |
function _sql_error()
|
|
indvdum@0
|
379 |
{
|
|
indvdum@0
|
380 |
return array(
|
|
indvdum@0
|
381 |
'message' => @odbc_errormsg(),
|
|
indvdum@0
|
382 |
'code' => @odbc_error()
|
|
indvdum@0
|
383 |
);
|
|
indvdum@0
|
384 |
}
|
|
indvdum@0
|
385 |
|
|
indvdum@0
|
386 |
/**
|
|
indvdum@0
|
387 |
* Close sql connection
|
|
indvdum@0
|
388 |
* @access private
|
|
indvdum@0
|
389 |
*/
|
|
indvdum@0
|
390 |
function _sql_close()
|
|
indvdum@0
|
391 |
{
|
|
indvdum@0
|
392 |
return @odbc_close($this->db_connect_id);
|
|
indvdum@0
|
393 |
}
|
|
indvdum@0
|
394 |
|
|
indvdum@0
|
395 |
/**
|
|
indvdum@0
|
396 |
* Build db-specific report
|
|
indvdum@0
|
397 |
* @access private
|
|
indvdum@0
|
398 |
*/
|
|
indvdum@0
|
399 |
function _sql_report($mode, $query = '')
|
|
indvdum@0
|
400 |
{
|
|
indvdum@0
|
401 |
switch ($mode)
|
|
indvdum@0
|
402 |
{
|
|
indvdum@0
|
403 |
case 'start':
|
|
indvdum@0
|
404 |
break;
|
|
indvdum@0
|
405 |
|
|
indvdum@0
|
406 |
case 'fromcache':
|
|
indvdum@0
|
407 |
$endtime = explode(' ', microtime());
|
|
indvdum@0
|
408 |
$endtime = $endtime[0] + $endtime[1];
|
|
indvdum@0
|
409 |
|
|
indvdum@0
|
410 |
$result = @odbc_exec($this->db_connect_id, $query);
|
|
indvdum@0
|
411 |
while ($void = @odbc_fetch_array($result))
|
|
indvdum@0
|
412 |
{
|
|
indvdum@0
|
413 |
// Take the time spent on parsing rows into account
|
|
indvdum@0
|
414 |
}
|
|
indvdum@0
|
415 |
@odbc_free_result($result);
|
|
indvdum@0
|
416 |
|
|
indvdum@0
|
417 |
$splittime = explode(' ', microtime());
|
|
indvdum@0
|
418 |
$splittime = $splittime[0] + $splittime[1];
|
|
indvdum@0
|
419 |
|
|
indvdum@0
|
420 |
$this->sql_report('record_fromcache', $query, $endtime, $splittime);
|
|
indvdum@0
|
421 |
|
|
indvdum@0
|
422 |
break;
|
|
indvdum@0
|
423 |
}
|
|
indvdum@0
|
424 |
}
|
|
indvdum@0
|
425 |
}
|
|
indvdum@0
|
426 |
|
|
indvdum@0
|
427 |
?> |