Documentation TYPO3 par Ameos

rsfilter.inc.php

00001 <?php
00015 /*
00016         Filter all fields and all rows in a recordset and returns the 
00017         processed recordset. We scroll to the beginning of the new recordset
00018         after processing.
00019         
00020         We pass a recordset and function name to RSFilter($rs,'rowfunc');
00021         and the function will be called multiple times, once
00022         for each row in the recordset. The function will be passed
00023         an array containing one row repeatedly.
00024         
00025         Example: 
00026         
00027         // ucwords() every element in the recordset
00028         function do_ucwords(&$arr,$rs)
00029         {
00030                 foreach($arr as $k => $v) {
00031                         $arr[$k] = ucwords($v);
00032                 }
00033         }
00034         $rs = RSFilter($rs,'do_ucwords');
00035  */
00036 function &RSFilter($rs,$fn)
00037 {
00038         if ($rs->databaseType != 'array') {
00039                 if (!$rs->connection) return false;
00040                 
00041                 $rs = &$rs->connection->_rs2rs($rs);
00042         }
00043         $rows = $rs->RecordCount();
00044         for ($i=0; $i < $rows; $i++) {
00045                 if (is_array ($fn)) {
00046                 $obj = $fn[0];
00047                 $method = $fn[1];
00048                 $obj->$method ($rs->_array[$i],$rs);
00049       } else {
00050                         $fn($rs->_array[$i],$rs);
00051       }
00052           
00053         }
00054         if (!$rs->EOF) {
00055                 $rs->_currentRow = 0;
00056                 $rs->fields = $rs->_array[0];
00057         }
00058         
00059         return $rs;
00060 }
00061 ?>


Généré par Le spécialiste TYPO3 avec  doxygen 1.4.6