source: trunk/client/class/db/mysql.php~@ 232

Last change on this file since 232 was 232, checked in by luc, 9 years ago
  • inclusione del tema per mobile Futura2 - inclusione del widget per la ricerca dei candidati - inclusione della segnalazione dell'installazione - altre piccole migliorie.

Inserita classe e file mancanti

File size: 6.0 KB
Line 
1<?php
2/***************************************************************************
3 * mysql.php
4 * -------------------
5 * begin : Saturday, Feb 13, 2001
6 * copyright : (C) 2001 The phpBB Group
7 * email : support@phpbb.com
8 *
9 * $Id: mysql.php,v 1.16 2002/03/19 01:07:36 psotfx Exp $
10 *
11 ***************************************************************************/
12
13/***************************************************************************
14 *
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
19 *
20 ***************************************************************************/
21
22if(!defined("SQL_LAYER"))
23{
24
25define("SQL_LAYER","mysql");
26
27class sql_db
28{
29
30 var $db_connect_id;
31 var $query_result;
32 var $row = array();
33 var $rowset = array();
34 var $num_queries = 0;
35
36 //
37 // Constructor
38 //
39 function sql_db($sqlserver, $sqluser, $sqlpassword, $database, $persistency = true)
40 {
41
42 $this->persistency = $persistency;
43 $this->user = $sqluser;
44 $this->password = $sqlpassword;
45 $this->server = $sqlserver;
46 $this->dbname = $database;
47
48 if($this->persistency)
49 {
50 $this->db_connect_id = @mysql_pconnect($this->server, $this->user, $this->password);
51 }
52 else
53 {
54 $this->db_connect_id = @mysql_connect($this->server, $this->user, $this->password);
55 }
56 if($this->db_connect_id)
57 {
58 if($database != "")
59 {
60 $this->dbname = $database;
61 $dbselect = @mysql_select_db($this->dbname);
62 if(!$dbselect)
63 {
64 @mysql_close($this->db_connect_id);
65 $this->db_connect_id = $dbselect;
66 }
67 }
68 return $this->db_connect_id;
69 }
70 else
71 {
72 return false;
73 }
74 }
75
76 //
77 // Other base methods
78 //
79 function sql_close()
80 {
81 if($this->db_connect_id)
82 {
83 if($this->query_result)
84 {
85 @mysql_free_result($this->query_result);
86 }
87 $result = @mysql_close($this->db_connect_id);
88 return $result;
89 }
90 else
91 {
92 return false;
93 }
94 }
95
96 //
97 // Base query method
98 //
99 function sql_query($query = "", $transaction = FALSE)
100 {
101 // Remove any pre-existing queries
102 unset($this->query_result);
103 if($query != "")
104 {
105
106 $this->query_result = @mysql_query($query, $this->db_connect_id);
107
108 }
109 if($this->query_result)
110 {
111 unset($this->row[$this->query_result]);
112 unset($this->rowset[$this->query_result]);
113 return $this->query_result;
114 }
115 else
116 {
117 return ( $transaction == END_TRANSACTION ) ? true : false;
118 }
119 }
120
121 //
122 // Other query methods
123 //
124 function sql_numrows($query_id = 0)
125 {
126 if(!$query_id)
127 {
128 $query_id = $this->query_result;
129 }
130 if($query_id)
131 {
132 $result = @mysql_num_rows($query_id);
133 return $result;
134 }
135 else
136 {
137 return false;
138 }
139 }
140 function sql_affectedrows()
141 {
142 if($this->db_connect_id)
143 {
144 $result = @mysql_affected_rows($this->db_connect_id);
145 return $result;
146 }
147 else
148 {
149 return false;
150 }
151 }
152 function sql_numfields($query_id = 0)
153 {
154 if(!$query_id)
155 {
156 $query_id = $this->query_result;
157 }
158 if($query_id)
159 {
160 $result = @mysql_num_fields($query_id);
161 return $result;
162 }
163 else
164 {
165 return false;
166 }
167 }
168 function sql_fieldname($offset, $query_id = 0)
169 {
170 if(!$query_id)
171 {
172 $query_id = $this->query_result;
173 }
174 if($query_id)
175 {
176 $result = @mysql_field_name($query_id, $offset);
177 return $result;
178 }
179 else
180 {
181 return false;
182 }
183 }
184 function sql_fieldtype($offset, $query_id = 0)
185 {
186 if(!$query_id)
187 {
188 $query_id = $this->query_result;
189 }
190 if($query_id)
191 {
192 $result = @mysql_field_type($query_id, $offset);
193 return $result;
194 }
195 else
196 {
197 return false;
198 }
199 }
200 function sql_fetchrow($query_id = 0)
201 {
202 if(!$query_id)
203 {
204 $query_id = $this->query_result;
205 }
206 if($query_id)
207 {
208 $this->row[$query_id] = @mysql_fetch_array($query_id);
209 return $this->row[$query_id];
210 }
211 else
212 {
213 return false;
214 }
215 }
216 function sql_fetchrowset($query_id = 0)
217 {
218 if(!$query_id)
219 {
220 $query_id = $this->query_result;
221 }
222 if($query_id)
223 {
224 unset($this->rowset[$query_id]);
225 unset($this->row[$query_id]);
226 while($this->rowset[$query_id] = @mysql_fetch_array($query_id))
227 {
228 $result[] = $this->rowset[$query_id];
229 }
230 return $result;
231 }
232 else
233 {
234 return false;
235 }
236 }
237 function sql_fetchfield($field, $rownum = -1, $query_id = 0)
238 {
239 if(!$query_id)
240 {
241 $query_id = $this->query_result;
242 }
243 if($query_id)
244 {
245 if($rownum > -1)
246 {
247 $result = @mysql_result($query_id, $rownum, $field);
248 }
249 else
250 {
251 if(empty($this->row[$query_id]) && empty($this->rowset[$query_id]))
252 {
253 if($this->sql_fetchrow())
254 {
255 $result = $this->row[$query_id][$field];
256 }
257 }
258 else
259 {
260 if($this->rowset[$query_id])
261 {
262 $result = $this->rowset[$query_id][$field];
263 }
264 else if($this->row[$query_id])
265 {
266 $result = $this->row[$query_id][$field];
267 }
268 }
269 }
270 return $result;
271 }
272 else
273 {
274 return false;
275 }
276 }
277 function sql_rowseek($rownum, $query_id = 0){
278 if(!$query_id)
279 {
280 $query_id = $this->query_result;
281 }
282 if($query_id)
283 {
284 $result = @mysql_data_seek($query_id, $rownum);
285 return $result;
286 }
287 else
288 {
289 return false;
290 }
291 }
292 function sql_nextid(){
293 if($this->db_connect_id)
294 {
295 $result = @mysql_insert_id($this->db_connect_id);
296 return $result;
297 }
298 else
299 {
300 return false;
301 }
302 }
303 function sql_freeresult($query_id = 0){
304 if(!$query_id)
305 {
306 $query_id = $this->query_result;
307 }
308
309 if ( $query_id )
310 {
311 unset($this->row[$query_id]);
312 unset($this->rowset[$query_id]);
313
314 @mysql_free_result($query_id);
315
316 return true;
317 }
318 else
319 {
320 return false;
321 }
322 }
323 function sql_error($query_id = 0)
324 {
325 $result["message"] = @mysql_error($this->db_connect_id);
326 $result["code"] = @mysql_errno($this->db_connect_id);
327
328 return $result;
329 }
330
331function sql_data_seek($query_id = 0)
332 {
333
334
335 return $result;
336 }
337
338
339
340} // class sql_db
341
342} // if ... define
343
344?>
Note: See TracBrowser for help on using the repository browser.