[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @version v5.20.3 01-Jan-2016 4 * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved. 5 * @copyright (c) 2014 Damien Regad, Mark Newnham and the ADOdb community 6 * Released under both BSD license and Lesser GPL library license. 7 * Whenever there is any discrepancy between the two licenses, 8 * the BSD license will take precedence. 9 * 10 * Set tabs to 4 for best viewing. 11 * 12 * Latest version is available at http://php.weblogs.com 13 * 14 * Requires PHP4.01pl2 or later because it uses include_once 15 */ 16 17 /* 18 Filter all fields and all rows in a recordset and returns the 19 processed recordset. We scroll to the beginning of the new recordset 20 after processing. 21 22 We pass a recordset and function name to RSFilter($rs,'rowfunc'); 23 and the function will be called multiple times, once 24 for each row in the recordset. The function will be passed 25 an array containing one row repeatedly. 26 27 Example: 28 29 // ucwords() every element in the recordset 30 function do_ucwords(&$arr,$rs) 31 { 32 foreach($arr as $k => $v) { 33 $arr[$k] = ucwords($v); 34 } 35 } 36 $rs = RSFilter($rs,'do_ucwords'); 37 */ 38 function RSFilter($rs,$fn) 39 { 40 if ($rs->databaseType != 'array') { 41 if (!$rs->connection) return false; 42 43 $rs = $rs->connection->_rs2rs($rs); 44 } 45 $rows = $rs->RecordCount(); 46 for ($i=0; $i < $rows; $i++) { 47 if (is_array ($fn)) { 48 $obj = $fn[0]; 49 $method = $fn[1]; 50 $obj->$method ($rs->_array[$i],$rs); 51 } else { 52 $fn($rs->_array[$i],$rs); 53 } 54 55 } 56 if (!$rs->EOF) { 57 $rs->_currentRow = 0; 58 $rs->fields = $rs->_array[0]; 59 } 60 61 return $rs; 62 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |