summaryrefslogtreecommitdiff
path: root/rsfilter.inc.php
diff options
context:
space:
mode:
authorDamien Regad <dregad@mantisbt.org>2013-08-05 13:56:24 +0200
committerDamien Regad <dregad@mantisbt.org>2013-08-05 13:56:24 +0200
commit53010b5ceb548968e93c752defec085e7c508f4a (patch)
tree332484926a4f961b6a12ca522f437e25bcace741 /rsfilter.inc.php
parent212c76c103997ef3aeb539517899ed42ddffdae4 (diff)
downloadadodb-53010b5ceb548968e93c752defec085e7c508f4a.tar.gz
adodb-53010b5ceb548968e93c752defec085e7c508f4a.tar.bz2
adodb-53010b5ceb548968e93c752defec085e7c508f4a.zip
Reorg: ADOdb5 (master) branch
- Move all files in adodb5/ to root - Remove adodb-for-php4/ directory
Diffstat (limited to 'rsfilter.inc.php')
-rw-r--r--rsfilter.inc.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/rsfilter.inc.php b/rsfilter.inc.php
new file mode 100644
index 00000000..8d4295a4
--- /dev/null
+++ b/rsfilter.inc.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * @version V4.93 10 Oct 2006 (c) 2000-2012 John Lim (jlim#natsoft.com). All rights reserved.
+ * Released under both BSD license and Lesser GPL library license.
+ * Whenever there is any discrepancy between the two licenses,
+ * the BSD license will take precedence.
+ *
+ * Set tabs to 4 for best viewing.
+ *
+ * Latest version is available at http://php.weblogs.com
+ *
+ * Requires PHP4.01pl2 or later because it uses include_once
+*/
+
+/*
+ Filter all fields and all rows in a recordset and returns the
+ processed recordset. We scroll to the beginning of the new recordset
+ after processing.
+
+ We pass a recordset and function name to RSFilter($rs,'rowfunc');
+ and the function will be called multiple times, once
+ for each row in the recordset. The function will be passed
+ an array containing one row repeatedly.
+
+ Example:
+
+ // ucwords() every element in the recordset
+ function do_ucwords(&$arr,$rs)
+ {
+ foreach($arr as $k => $v) {
+ $arr[$k] = ucwords($v);
+ }
+ }
+ $rs = RSFilter($rs,'do_ucwords');
+ */
+function RSFilter($rs,$fn)
+{
+ if ($rs->databaseType != 'array') {
+ if (!$rs->connection) return false;
+
+ $rs = $rs->connection->_rs2rs($rs);
+ }
+ $rows = $rs->RecordCount();
+ for ($i=0; $i < $rows; $i++) {
+ if (is_array ($fn)) {
+ $obj = $fn[0];
+ $method = $fn[1];
+ $obj->$method ($rs->_array[$i],$rs);
+ } else {
+ $fn($rs->_array[$i],$rs);
+ }
+
+ }
+ if (!$rs->EOF) {
+ $rs->_currentRow = 0;
+ $rs->fields = $rs->_array[0];
+ }
+
+ return $rs;
+}
+?> \ No newline at end of file