MDL-78165 mod_bigbluebuttonbn: Fetch cron status using API
[moodle.git] / lib / adodb / rsfilter.inc.php
blob34c5311cf6fb3abf781189f2391dfc390d1ebba1
1 <?php
2 /**
3 * RecordSet Filter.
5 * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
7 * @package ADOdb
8 * @link https://adodb.org Project's web site and documentation
9 * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
11 * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
12 * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
13 * any later version. This means you can use it in proprietary products.
14 * See the LICENSE.md file distributed with this source code for details.
15 * @license BSD-3-Clause
16 * @license LGPL-2.1-or-later
18 * @copyright 2000-2013 John Lim
19 * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
23 Filter all fields and all rows in a recordset and returns the
24 processed recordset. We scroll to the beginning of the new recordset
25 after processing.
27 We pass a recordset and function name to RSFilter($rs,'rowfunc');
28 and the function will be called multiple times, once
29 for each row in the recordset. The function will be passed
30 an array containing one row repeatedly.
32 Example:
34 // ucwords() every element in the recordset
35 function do_ucwords(&$arr,$rs)
37 foreach($arr as $k => $v) {
38 $arr[$k] = ucwords($v);
41 $rs = RSFilter($rs,'do_ucwords');
43 function RSFilter($rs,$fn)
45 if ($rs->databaseType != 'array') {
46 if (!$rs->connection) return false;
48 $rs = $rs->connection->_rs2rs($rs);
50 $rows = $rs->RecordCount();
51 for ($i=0; $i < $rows; $i++) {
52 if (is_array ($fn)) {
53 $obj = $fn[0];
54 $method = $fn[1];
55 $obj->$method ($rs->_array[$i],$rs);
56 } else {
57 $fn($rs->_array[$i],$rs);
61 if (!$rs->EOF) {
62 $rs->_currentRow = 0;
63 $rs->fields = $rs->_array[0];
66 return $rs;