1: <?php
2: /**
3: * You may not change or alter any portion of this comment or credits
4: * of supporting developers from this source code or any supporting source code
5: * which is considered copyrighted (c) material of the original comment or credit authors.
6: *
7: * This program is distributed in the hope that it will be useful,
8: * but WITHOUT ANY WARRANTY; without even the implied warranty of
9: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: /**
13: * Abstract base class for Database access classes
14: *
15: * PHP version 5.3
16: *
17: * @category Xoops\Class\Database\Database
18: * @package Database
19: * @author Kazumi Ono <onokazu@xoops.org>
20: * @copyright 2013 XOOPS Project (http://xoops.org)
21: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
22: * @version Release:2.6
23: * @link http://xoops.org
24: * @since 2.6.0
25: * @abstract
26: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
27: */
28: abstract class XoopsDatabase
29: {
30: /**
31: * Database connection
32: *
33: * @var resource
34: */
35: public $conn;
36:
37: /**
38: * Prefix for tables in the database
39: *
40: * @var string
41: */
42: public $prefix = '';
43:
44: /**
45: * If statements that modify the database are selected
46: *
47: * @var boolean
48: */
49: public $allowWebChanges = false;
50:
51:
52: /**
53: * set the prefix for tables in the database
54: *
55: * @param string $value table prefix
56: *
57: * @return this does not return a value
58: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
59: */
60: public function setPrefix($value)
61: {
62: $this->prefix = $value;
63: }
64:
65: /**
66: * public function prefix($tablename = '')
67: *
68: * attach the prefix.'_' to a given tablename
69: * if tablename is empty, only prefix will be returned
70: *
71: * @param string $tablename tablename
72: *
73: * @return string prefixed tablename, just prefix if tablename is empty
74: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
75: */
76: public function prefix($tablename = '')
77: {
78:
79: if ($tablename != '') {
80: return $this->prefix . '_' . $tablename;
81: } else {
82: return $this->prefix;
83: }
84: }
85:
86: /**
87: * connect to the database
88: *
89: * @param bool $selectdb select the database now?
90: *
91: * @return bool successful?
92: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
93: * @abstract
94: *
95: */
96: abstract public function connect($selectdb = true);
97:
98: /**
99: * generate an ID for a new row
100: *
101: * This is for compatibility only. Will always return 0, because MySQL supports
102: * autoincrement for primary keys.
103: *
104: * @param string $sequence name of the sequence from which to get the next ID
105: *
106: * @return int always 0, because mysql has support for autoincrement
107: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
108: * @abstract
109: */
110: abstract public function genId($sequence);
111:
112: /**
113: * Get a result row as an enumerated array
114: *
115: * @param resource $result resource to get result from
116: *
117: * @return array
118: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
119: * @abstract
120: */
121: abstract public function fetchRow($result);
122:
123: /**
124: * Fetch a result row as an associative array
125: *
126: * @param resource $result resource to get result from
127: *
128: * @return array
129: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
130: * @abstract
131: */
132: abstract public function fetchArray($result);
133:
134: /**
135: * Fetch a result row as an associative array
136: *
137: * @param resource $result resource to get result from
138: *
139: * @return array
140: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
141: * @abstract
142: */
143: abstract public function fetchBoth($result);
144:
145: /**
146: * Fetch a result row as an object
147: *
148: * @param resource $result resource to get result from
149: *
150: * @return object|stdClass
151: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
152: * @abstract
153: */
154: abstract public function fetchObject($result);
155:
156: /**
157: * Get the ID generated from the previous INSERT operation
158: *
159: * @return int
160: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
161: * @abstract
162: */
163: abstract public function getInsertId();
164:
165: /**
166: * Get number of rows in result
167: *
168: * @param resource $result the resource containing the number of rows
169: *
170: * @return int the number of rows to return
171: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
172: * @abstract
173: */
174: abstract public function getRowsNum($result);
175:
176: /**
177: * Get number of affected rows
178: *
179: * @return int
180: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
181: * @abstract
182: */
183: abstract public function getAffectedRows();
184:
185: /**
186: * Close MySQL connection
187: *
188: * @return void
189: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
190: * @abstract
191: */
192: abstract public function close();
193:
194: /**
195: * Free all memory associated with the result identifier result.
196: *
197: * @param resource $result query result
198: *
199: * @return bool TRUE on success or FALSE on failure.
200: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
201: * @abstract
202: */
203: abstract public function freeRecordSet($result);
204:
205: /**
206: * Returns the text of the error message from previous MySQL operation
207: *
208: * @return bool Returns the error text from the last MySQL function,
209: * or '' (the empty string) if no error occurred.
210: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
211: * @abstract
212: */
213: abstract public function error();
214:
215: /**
216: * Returns the numerical value of the error message from previous
217: * MySQL operation
218: *
219: * @return int Returns the error number from the last MySQL function
220: * , or 0 (zero) if no error occurred.
221: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
222: * @abstract
223: */
224: abstract public function errno();
225:
226: /**
227: * Returns escaped string text with single
228: * quotes around it to be safely stored in database
229: *
230: * @param string $str unescaped string text
231: *
232: * @return string escaped string text with single quotes around
233: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
234: * @abstract
235: */
236: abstract public function quoteString($str);
237:
238: /**
239: * Quotes a string for use in a query.
240: *
241: * @param string $string string to quote
242: *
243: * @return string
244: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
245: * @abstract
246: */
247: abstract public function quote($string);
248:
249: /**
250: * Returns escaped string text without quotes around it
251: *
252: * @param string $string unescaped string text
253: *
254: * @return string escaped text string escaped to be safely used in database calls
255: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
256: * @abstract
257: */
258: abstract public function escape($string);
259:
260: /**
261: * perform a query on the database
262: *
263: * @param string $sql a valid MySQL query
264: * @param int $limit number of records to return
265: * @param int $start offset of first record to return
266: *
267: * @return bool|resource query result or FALSE if successful
268: * or TRUE if successful and no result
269: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
270: * @abstract
271: */
272: abstract public function queryF($sql, $limit = 0, $start = 0);
273:
274: /**
275: * perform a query
276: *
277: * This method is empty and does nothing! It should therefore only be
278: * used if nothing is exactly what you want done! ;-)
279: *
280: * @param string $sql a valid MySQL query
281: * @param int $limit number of records to return
282: * @param int $start offset of first record to return
283: *
284: * @return resource returns nothing
285: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
286: * @abstract
287: */
288: abstract public function query($sql, $limit = 0, $start = 0);
289:
290: /**
291: * perform queries from SQL dump file in a batch
292: *
293: * @param string $file file path to an SQL dump file
294: *
295: * @return bool FALSE if failed reading SQL file or TRUE
296: * if the file has been read and queries executed
297: * @deprecated since version 2.6.0 - alpha 3
298: * @abstract
299: */
300: abstract public function queryFromFile($file);
301:
302: /**
303: * Get field name
304: *
305: * @param resource $result query result
306: * @param int $offset numerical field index
307: *
308: * @return string
309: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
310: * @abstract
311: */
312: abstract public function getFieldName($result, $offset);
313:
314: /**
315: * Get field type
316: *
317: * @param resource $result query result
318: * @param int $offset numerical field index
319: *
320: * @return string
321: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
322: * @abstract
323: */
324: abstract public function getFieldType($result, $offset);
325:
326: /**
327: * Get number of fields in result
328: *
329: * @param resource $result query result
330: *
331: * @return int
332: * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
333: * @abstract
334: */
335: abstract public function getFieldsNum($result);
336: }
337: