Fixed bug #17662: Remove deprecated class gzip_encode
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_sqlengine.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2004-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * PHP SQL engine
29 * EXPERIMENTAL!
30 *
31 * $Id$
32 *
33 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
34 * @deprecated since TYPO3 4.3, this class will be removed in TYPO3 4.5, it has been integrated to extension DBAL.
35 */
36 /**
37 * [CLASS/FUNCTION INDEX of SCRIPT]
38 *
39 *
40 *
41 * 104: class t3lib_sqlengine extends t3lib_sqlparser
42 * 126: function init($config, &$pObj)
43 * 134: function resetStatusVars()
44 * 150: function processAccordingToConfig(&$value,$fInfo)
45 *
46 * SECTION: SQL queries
47 * 205: function exec_INSERTquery($table,$fields_values)
48 * 273: function exec_UPDATEquery($table,$where,$fields_values)
49 * 332: function exec_DELETEquery($table,$where)
50 * 383: function exec_SELECTquery($select_fields,$from_table,$where_clause,$groupBy,$orderBy,$limit)
51 * 426: function sql_query($query)
52 * 437: function sql_error()
53 * 446: function sql_insert_id()
54 * 455: function sql_affected_rows()
55 * 465: function quoteStr($str)
56 *
57 * SECTION: SQL admin functions
58 * 490: function admin_get_tables()
59 * 501: function admin_get_fields($tableName)
60 * 512: function admin_get_keys($tableName)
61 * 523: function admin_query($query)
62 *
63 * SECTION: Data Source I/O
64 * 548: function readDataSource($table)
65 * 560: function saveDataSource($table)
66 *
67 * SECTION: SQL engine functions (PHP simulation of SQL) - still experimental
68 * 590: function selectFromData($table,$where)
69 * 628: function select_evalSingle($table,$config,&$itemKeys)
70 * 747: function getResultSet($keys, $table, $fieldList)
71 *
72 * SECTION: Debugging
73 * 790: function debug_printResultSet($array)
74 *
75 *
76 * 829: class t3lib_sqlengine_resultobj
77 * 843: function sql_num_rows()
78 * 852: function sql_fetch_assoc()
79 * 863: function sql_fetch_row()
80 * 881: function sql_data_seek($pointer)
81 * 894: function sql_field_type()
82 *
83 * TOTAL FUNCTIONS: 27
84 * (This index is automatically created/updated by the extension "extdeveval")
85 *
86 */
87
88
89 /**
90 * PHP SQL engine / server
91 * Basically this is trying to emulation SQL record selection by PHP, thus allowing SQL queries into alternative data storages managed by PHP.
92 * EXPERIMENTAL!
93 *
94 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
95 * @package TYPO3
96 * @subpackage t3lib
97 */
98 class t3lib_sqlengine extends t3lib_sqlparser {
99
100 // array with data records: [table name][num.index] = records
101 var $data = array(); // Data source storage
102
103
104 // Internal, SQL Status vars:
105 var $errorStatus = ''; // Set with error message of last operation
106 var $lastInsertedId = 0; // Set with last inserted unique ID
107 var $lastAffectedRows = 0; // Set with last number of affected rows.
108
109
110 /**
111 * Constrcutor
112 */
113 function __construct() {
114 t3lib_div::deprecationLog("Class t3lib_sqlengine is deprecated since TYPO3 4.3, will be removed in TYPO3 4.6, it has been integrated to extension DBAL.");
115 }
116
117
118 /**
119 * Dummy function for initializing SQL handler. Create you own in derived classes.
120 *
121 * @param array Configuration array from handler
122 * @param object Parent object
123 * @return void
124 */
125 function init($config, $pObj) {
126 }
127
128 /**
129 * Reset SQL engine status variables (insert id, affected rows, error status)
130 *
131 * @return void
132 */
133 function resetStatusVars() {
134 $this->errorStatus = '';
135 $this->lastInsertedId = 0;
136 $this->lastAffectedRows = 0;
137 }
138
139 /**
140 * Processing of update/insert values based on field type.
141 *
142 * The input value is typecast and trimmed/shortened according to the field
143 * type and the configuration options from the $fInfo parameter.
144 *
145 * @param mixed $value The input value to process
146 * @param array $fInfo Field configuration data
147 * @return mixed The processed input value
148 */
149 function processAccordingToConfig(&$value, $fInfo) {
150 $options = $this->parseFieldDef($fInfo['Type']);
151
152 switch (strtolower($options['fieldType'])) {
153 case 'int':
154 case 'smallint':
155 case 'tinyint':
156 case 'mediumint':
157 $value = intval($value);
158 if ($options['featureIndex']['UNSIGNED']) {
159 $value = t3lib_div::intInRange($value, 0);
160 }
161 break;
162 case 'double':
163 $value = (double) $value;
164 break;
165 case 'varchar':
166 case 'char':
167 $value = substr($value, 0, trim($options['value']));
168 break;
169 case 'text':
170 case 'blob':
171 $value = substr($value, 0, 65536);
172 break;
173 case 'tinytext':
174 case 'tinyblob':
175 $value = substr($value, 0, 256);
176 break;
177 case 'mediumtext':
178 case 'mediumblob':
179 // ??
180 break;
181 }
182 }
183
184
185 /********************************
186 *
187 * SQL queries
188 * This is the SQL access functions used when this class is instantiated as a SQL handler with DBAL. Override these in derived classes.
189 *
190 ********************************/
191
192 /**
193 * Execute an INSERT query
194 *
195 * @param string Table name
196 * @param array Field values as key=>value pairs.
197 * @return boolean TRUE on success and FALSE on failure (error is set internally)
198 */
199 function exec_INSERTquery($table, $fields_values) {
200
201 // Initialize
202 $this->resetStatusVars();
203
204 // Reading Data Source if not done already.
205 $this->readDataSource($table);
206
207 // If data source is set:
208 if (is_array($this->data[$table])) {
209
210 $fieldInformation = $this->admin_get_fields($table); // Should cache this...!
211
212 // Looking for unique keys:
213 $saveArray = array();
214 foreach ($fieldInformation as $fInfo) {
215
216 // Field name:
217 $fN = $fInfo['Field'];
218
219 // Set value:
220 // FIXME $options not defined
221 $saveArray[$fN] = isset($fields_values[$fN]) ? $fields_values[$fN] : $options['Default'];
222
223 // Process value:
224 $this->processAccordingToConfig($saveArray[$fN], $fInfo);
225
226 // If an auto increment field is found, find the largest current uid:
227 if ($fInfo['Extra'] == 'auto_increment') {
228
229 // Get all UIDs:
230 $uidArray = array();
231 foreach ($this->data[$table] as $r) {
232 $uidArray[] = $r[$fN];
233 }
234
235 // If current value is blank or already in array, we create a new:
236 if (!$saveArray[$fN] || in_array(intval($saveArray[$fN]), $uidArray)) {
237 if (count($uidArray)) {
238 $saveArray[$fN] = max($uidArray) + 1;
239 } else {
240 $saveArray[$fN] = 1;
241 }
242 }
243
244 // Update "last inserted id":
245 $this->lastInsertedId = $saveArray[$fN];
246 }
247 }
248
249 // Insert row in table:
250 $this->data[$table][] = $saveArray;
251
252 // Save data source
253 $this->saveDataSource($table);
254
255 return TRUE;
256 } else {
257 $this->errorStatus = 'No data loaded.';
258 }
259
260 return FALSE;
261 }
262
263 /**
264 * Execute UPDATE query on table
265 *
266 * @param string Table name
267 * @param string WHERE clause
268 * @param array Field values as key=>value pairs.
269 * @return boolean TRUE on success and FALSE on failure (error is set internally)
270 */
271 function exec_UPDATEquery($table, $where, $fields_values) {
272
273 // Initialize:
274 $this->resetStatusVars();
275
276 // Reading Data Source if not done already.
277 $this->readDataSource($table);
278
279 // If anything is there:
280 if (is_array($this->data[$table])) {
281
282 // Parse WHERE clause:
283 $where = $this->parseWhereClause($where);
284
285 if (is_array($where)) {
286
287 // Field information
288 $fieldInformation = $this->admin_get_fields($table); // Should cache this...!
289
290 // Traverse fields to update:
291 foreach ($fields_values as $fName => $fValue) {
292 $this->processAccordingToConfig($fields_values[$fName], $fieldInformation[$fName]);
293 }
294
295 // Do query, returns array with keys to the data array of the result:
296 $itemKeys = $this->selectFromData($table, $where);
297
298 // Set "last affected rows":
299 $this->lastAffectedRows = count($itemKeys);
300
301 // Update rows:
302 if ($this->lastAffectedRows) {
303 // Traverse result set here:
304 foreach ($itemKeys as $dataArrayKey) {
305
306 // Traverse fields to update:
307 foreach ($fields_values as $fName => $fValue) {
308 $this->data[$table][$dataArrayKey][$fName] = $fValue;
309 }
310 }
311
312 // Save data source
313 $this->saveDataSource($table);
314 }
315
316 return TRUE;
317 } else {
318 $this->errorStatus = 'WHERE clause contained errors: ' . $where;
319 }
320 } else {
321 $this->errorStatus = 'No data loaded.';
322 }
323
324 return FALSE;
325 }
326
327 /**
328 * Execute DELETE query
329 *
330 * @param string Table to delete from
331 * @param string WHERE clause
332 * @return boolean TRUE on success and FALSE on failure (error is set internally)
333 */
334 function exec_DELETEquery($table, $where) {
335
336 // Initialize:
337 $this->resetStatusVars();
338
339 // Reading Data Source if not done already.
340 $this->readDataSource($table);
341
342 // If anything is there:
343 if (is_array($this->data[$table])) {
344
345 // Parse WHERE clause:
346 $where = $this->parseWhereClause($where);
347
348 if (is_array($where)) {
349
350 // Do query, returns array with keys to the data array of the result:
351 $itemKeys = $this->selectFromData($table, $where);
352
353 // Set "last affected rows":
354 $this->lastAffectedRows = count($itemKeys);
355
356 // Remove rows:
357 if ($this->lastAffectedRows) {
358 // Traverse result set:
359 foreach ($itemKeys as $dataArrayKey) {
360 unset($this->data[$table][$dataArrayKey]);
361 }
362
363 // Saving data source
364 $this->saveDataSource($table);
365 }
366
367 return TRUE;
368 } else {
369 $this->errorStatus = 'WHERE clause contained errors: ' . $where;
370 }
371 } else {
372 $this->errorStatus = 'No data loaded.';
373 }
374
375 return FALSE;
376 }
377
378 /**
379 * Execute SELECT query
380 *
381 * @param string List of fields to select from the table. This is what comes right after "SELECT ...". Required value.
382 * @param string Table(s) from which to select. This is what comes right after "FROM ...". Required value.
383 * @param string Optional additional WHERE clauses put in the end of the query. NOTICE: You must escape values in this argument with $this->fullQuoteStr() yourself! DO NOT PUT IN GROUP BY, ORDER BY or LIMIT!
384 * @param string Optional GROUP BY field(s), if none, supply blank string.
385 * @param string Optional ORDER BY field(s), if none, supply blank string.
386 * @param string Optional LIMIT value ([begin,]max), if none, supply blank string.
387 * @return object Returns result object, but if errors, returns false
388 */
389 function exec_SELECTquery($select_fields, $from_table, $where_clause, $groupBy, $orderBy, $limit) {
390
391 // Initialize:
392 $this->resetStatusVars();
393
394 // Create result object
395 $sqlObj = t3lib_div::makeInstance('t3lib_sqlengine_resultobj');
396 $sqlObj->result = array(); // Empty result as a beginning
397
398 // Get table list:
399 $tableArray = $this->parseFromTables($from_table);
400 $table = $tableArray[0]['table'];
401
402 // Reading Data Source if not done already.
403 $this->readDataSource($table);
404
405 // If anything is there:
406 if (is_array($this->data[$table])) {
407
408 // Parse WHERE clause:
409 $where = $this->parseWhereClause($where_clause);
410 if (is_array($where)) {
411
412 // Do query, returns array with keys to the data array of the result:
413 $itemKeys = $this->selectFromData($table, $where);
414
415 // Finally, read the result rows into this variable:
416 $sqlObj->result = $this->getResultSet($itemKeys, $table, '*');
417 // Reset and return result:
418 reset($sqlObj->result);
419 return $sqlObj;
420 } else {
421 $this->errorStatus = 'WHERE clause contained errors: ' . $where;
422 }
423 } else {
424 $this->errorStatus = 'No data loaded: ' . $this->errorStatus;
425 }
426
427 return FALSE;
428 }
429
430 /**
431 * Performs an SQL query on the "database"
432 *
433 * @param string Query to execute
434 * @return object Result object or false if error
435 */
436 function sql_query($query) {
437 $res = t3lib_div::makeInstance('t3lib_sqlengine_resultobj');
438 $res->result = array();
439 return $res;
440 }
441
442 /**
443 * Returns most recent error
444 *
445 * @return string Error message, if any
446 */
447 function sql_error() {
448 return $this->errorStatus;
449 }
450
451 /**
452 * Returns most recently create unique ID (of INSERT queries)
453 *
454 * @return integer Last unique id created.
455 */
456 function sql_insert_id() {
457 return $this->lastInsertedId;
458 }
459
460 /**
461 * Returns affected rows (of UPDATE and DELETE queries)
462 *
463 * @return integer Last amount of affected rows.
464 */
465 function sql_affected_rows() {
466 return $this->lastAffectedRows;
467 }
468
469 /**
470 * Quoting strings for insertion in SQL queries
471 *
472 * @param string Input String
473 * @return string String, with quotes escaped
474 */
475 function quoteStr($str) {
476 return addslashes($str);
477 }
478
479
480 /**************************************
481 *
482 * SQL admin functions
483 * (For use in the Install Tool and Extension Manager)
484 *
485 **************************************/
486
487 /**
488 * (DUMMY) Returns the list of tables from the database
489 *
490 * @return array Tables in an array (tablename is in both key and value)
491 * @todo Should return table details in value! see t3lib_db::admin_get_tables()
492 */
493 function admin_get_tables() {
494 $whichTables = array();
495 return $whichTables;
496 }
497
498 /**
499 * (DUMMY) Returns information about each field in the $table
500 *
501 * @param string Table name
502 * @return array Field information in an associative array with fieldname => field row
503 */
504 function admin_get_fields($tableName) {
505 $output = array();
506 return $output;
507 }
508
509 /**
510 * (DUMMY) Returns information about each index key in the $table
511 *
512 * @param string Table name
513 * @return array Key information in a numeric array
514 */
515 function admin_get_keys($tableName) {
516 $output = array();
517 return $output;
518 }
519
520 /**
521 * (DUMMY) mysql() wrapper function, used by the Install Tool and EM for all queries regarding management of the database!
522 *
523 * @param string Query to execute
524 * @return pointer Result pointer
525 */
526 function admin_query($query) {
527 return $this->sql_query($query);
528 }
529
530
531 /********************************
532 *
533 * Data Source I/O
534 *
535 ********************************/
536
537 /**
538 * Dummy function for setting table data. Create your own.
539 * NOTICE: Handler to "table-locking" needs to be made probably!
540 *
541 * @param string Table name
542 * @return void
543 * @todo Table locking tools?
544 */
545 function readDataSource($table) {
546 $this->data[$table] = array();
547 }
548
549 /**
550 * Dummy function for setting table data. Create your own.
551 * NOTICE: Handler to "table-locking" needs to be made probably!
552 *
553 * @param string Table name
554 * @return void
555 * @todo Table locking tools?
556 */
557 function saveDataSource($table) {
558 debug($this->data[$table]);
559 }
560
561
562 /********************************
563 *
564 * SQL engine functions (PHP simulation of SQL) - still experimental
565 *
566 ********************************/
567
568 /**
569 * PHP simulation of SQL "SELECT"
570 * Yet EXPERIMENTAL!
571 *
572 * @param string Table name
573 * @param array Where clause parsed into array
574 * @return array Array of keys pointing to result rows in $this->data[$table]
575 */
576 function selectFromData($table, $where) {
577
578 $output = array();
579 if (is_array($this->data[$table])) {
580
581 // All keys:
582 $OR_index = 0;
583 $itemKeys = array();
584
585 foreach ($where as $config) {
586
587 if (strtoupper($config['operator']) == 'OR') {
588 $OR_index++;
589 }
590
591 if (!isset($itemKeys[$OR_index])) {
592 $itemKeys[$OR_index] = array_keys($this->data[$table]);
593 }
594
595 $this->select_evalSingle($table, $config, $itemKeys[$OR_index]);
596 }
597
598 foreach ($itemKeys as $uidKeys) {
599 $output = array_merge($output, $uidKeys);
600 }
601 $output = array_unique($output);
602 }
603
604 return $output;
605 }
606
607 /**
608 * Evalutaion of a WHERE-clause-array.
609 * Yet EXPERIMENTAL
610 *
611 * @param string Tablename
612 * @param array WHERE-configuration array
613 * @param array Data array to work on.
614 * @return void Data array passed by reference
615 * @see selectFromData()
616 */
617 function select_evalSingle($table, $config, &$itemKeys) {
618 $neg = preg_match('/^AND[[:space:]]+NOT$/', trim($config['operator']));
619
620 if (is_array($config['sub'])) {
621 $subSelKeys = $this->selectFromData($table, $config['sub']);
622 if ($neg) {
623 foreach ($itemKeys as $kk => $vv) {
624 if (in_array($vv, $subSelKeys)) {
625 unset($itemKeys[$kk]);
626 }
627 }
628 } else {
629 $itemKeys = array_intersect($itemKeys, $subSelKeys);
630 }
631 } else {
632 $comp = strtoupper(str_replace(array(' ', TAB, CR, LF), '', $config['comparator']));
633 $mod = strtoupper($config['modifier']);
634 switch ($comp) {
635 case 'NOTLIKE':
636 case 'LIKE':
637 $like_value = strtolower($config['value'][0]);
638 if (substr($like_value, 0, 1) == '%') {
639 $wildCard_begin = TRUE;
640 $like_value = substr($like_value, 1);
641 }
642 if (substr($like_value, -1) == '%') {
643 $wildCard_end = TRUE;
644 $like_value = substr($like_value, 0, -1);
645 }
646 break;
647 case 'NOTIN':
648 case 'IN':
649 $in_valueArray = array();
650 foreach ($config['value'] as $vParts) {
651 $in_valueArray[] = (string) $vParts[0];
652 }
653 break;
654 }
655
656 foreach ($itemKeys as $kk => $v) {
657 $field_value = $this->data[$table][$v][$config['field']];
658
659 // Calculate it:
660 if ($config['calc'] == '&') {
661 $field_value &= intval($config['calc_value']);
662 }
663
664 // Compare it:
665 switch ($comp) {
666 case '<=':
667 $bool = $field_value <= $config['value'][0];
668 break;
669 case '>=':
670 $bool = $field_value >= $config['value'][0];
671 break;
672 case '<':
673 $bool = $field_value < $config['value'][0];
674 break;
675 case '>':
676 $bool = $field_value > $config['value'][0];
677 break;
678 case '=':
679 $bool = !strcmp($field_value, $config['value'][0]);
680 break;
681 case '!=':
682 $bool = strcmp($field_value, $config['value'][0]);
683 break;
684 case 'NOTIN':
685 case 'IN':
686 $bool = in_array((string) $field_value, $in_valueArray);
687 if ($comp == 'NOTIN') {
688 $bool = !$bool;
689 }
690 break;
691 case 'NOTLIKE':
692 case 'LIKE':
693 if (!strlen($like_value)) {
694 $bool = TRUE;
695 } elseif ($wildCard_begin && !$wildCard_end) {
696 $bool = !strcmp(substr(strtolower($field_value), -strlen($like_value)), $like_value);
697 } elseif (!$wildCard_begin && $wildCard_end) {
698 $bool = !strcmp(substr(strtolower($field_value), 0, strlen($like_value)), $like_value);
699 } elseif ($wildCard_begin && $wildCard_end) {
700 $bool = strstr($field_value, $like_value);
701 } else {
702 $bool = !strcmp(strtolower($field_value), $like_value);
703 }
704 if ($comp == 'NOTLIKE') {
705 $bool = !$bool;
706 }
707 break;
708 default:
709 $bool = $field_value ? TRUE : FALSE;
710 break;
711 }
712
713 // General negation:
714 if ($neg) {
715 $bool = !$bool;
716 }
717
718 // Modify?
719 switch ($mod) {
720 case 'NOT':
721 case '!':
722 $bool = !$bool;
723 break;
724 }
725
726 // Action:
727 if (!$bool) {
728 unset($itemKeys[$kk]);
729 }
730 }
731 }
732 }
733
734 /**
735 * Returning result set based on result keys, table and field list
736 *
737 * @param array Result keys
738 * @param string Tablename
739 * @param string Fieldlist (commaseparated)
740 * @return array Result array with "rows"
741 */
742 function getResultSet($keys, $table, $fieldList) {
743 $fields = t3lib_div::trimExplode(',', $fieldList);
744
745 $output = array();
746 foreach ($keys as $kValue) {
747 if ($fieldList == '*') {
748 $output[$kValue] = $this->data[$table][$kValue];
749 } else {
750 foreach ($fields as $fieldName) {
751 $output[$kValue][$fieldName] = $this->data[$table][$kValue][$fieldName];
752 }
753 }
754 }
755
756 return $output;
757 }
758
759
760 /*************************
761 *
762 * Debugging
763 *
764 *************************/
765
766 /**
767 * Returns the result set (in array) as HTML table. For debugging.
768 *
769 * @param array Result set array (array of rows)
770 * @return string HTML table
771 */
772 function debug_printResultSet($array) {
773
774 if (count($array)) {
775 $tRows = array();
776 $fields = array_keys(current($array));
777 $tCell[] = '
778 <td>IDX</td>';
779 foreach ($fields as $fieldName) {
780 $tCell[] = '
781 <td>' . htmlspecialchars($fieldName) . '</td>';
782 }
783 $tRows[] = '<tr>' . implode('', $tCell) . '</tr>';
784
785
786 foreach ($array as $index => $rec) {
787
788 $tCell = array();
789 $tCell[] = '
790 <td>' . htmlspecialchars($index) . '</td>';
791 foreach ($fields as $fieldName) {
792 $tCell[] = '
793 <td>' . htmlspecialchars($rec[$fieldName]) . '</td>';
794 }
795 $tRows[] = '<tr>' . implode('', $tCell) . '</tr>';
796 }
797
798 return '<table border="1">' . implode('', $tRows) . '</table>';
799 } else {
800 'Empty resultset';
801 }
802 }
803 }
804
805
806 /**
807 * PHP SQL engine, result object
808 *
809 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
810 * @package TYPO3
811 * @subpackage t3lib
812 */
813 class t3lib_sqlengine_resultobj {
814
815 // Result array, must contain the fields in the order they were selected in the SQL statement (for sql_fetch_row())
816 var $result = array();
817
818 var $TYPO3_DBAL_handlerType = '';
819 var $TYPO3_DBAL_tableList = '';
820
821 /**
822 * Constrcutor
823 */
824 function __construct() {
825 t3lib_div::deprecationLog("Class t3lib_sqlengine_resultobj is deprecated since TYPO3 4.3, will be removed in TYPO3 4.6, it has been integrated to extension DBAL.");
826 }
827
828 /**
829 * Counting number of rows
830 *
831 * @return integer
832 */
833 function sql_num_rows() {
834 return count($this->result);
835 }
836
837 /**
838 * Fetching next row in result array
839 *
840 * @return array Associative array
841 */
842 function sql_fetch_assoc() {
843 $row = current($this->result);
844 next($this->result);
845 return $row;
846 }
847
848 /**
849 * Fetching next row, numerical indices
850 *
851 * @return array Numerical array
852 */
853 function sql_fetch_row() {
854 $resultRow = $this->sql_fetch_assoc();
855
856 if (is_array($resultRow)) {
857 $numArray = array();
858 foreach ($resultRow as $value) {
859 $numArray[] = $value;
860 }
861 return $numArray;
862 }
863 }
864
865 /**
866 * Seeking position in result
867 *
868 * @param integer Position pointer.
869 * @return boolean Returns true on success
870 */
871 function sql_data_seek($pointer) {
872 reset($this->result);
873 for ($a = 0; $a < $pointer; $a++) {
874 next($this->result);
875 }
876 return TRUE;
877 }
878
879 /**
880 * Returning SQL field type
881 *
882 * @return string Blank string, not supported (it seems)
883 */
884 function sql_field_type() {
885 return '';
886 }
887 }
888
889
890 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlengine.php'])) {
891 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_sqlengine.php']);
892 }
893
894 ?>