updated adodb package to work with php 7.1
[openemr.git] / vendor / adodb / adodb-php / rsfilter.inc.php
blob4b609b98bf9176fedecf77052c5512c50e646407
1 <?php
2 /**
3 * @version v5.20.9 21-Dec-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.
10 * Set tabs to 4 for best viewing.
12 * Latest version is available at http://php.weblogs.com
14 * Requires PHP4.01pl2 or later because it uses include_once
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.
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.
27 Example:
29 // ucwords() every element in the recordset
30 function do_ucwords(&$arr,$rs)
32 foreach($arr as $k => $v) {
33 $arr[$k] = ucwords($v);
36 $rs = RSFilter($rs,'do_ucwords');
38 function RSFilter($rs,$fn)
40 if ($rs->databaseType != 'array') {
41 if (!$rs->connection) return false;
43 $rs = $rs->connection->_rs2rs($rs);
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);
56 if (!$rs->EOF) {
57 $rs->_currentRow = 0;
58 $rs->fields = $rs->_array[0];
61 return $rs;