The method "getbyfunction" currently accepts the
following arguments:
* selectfn, a function that accepts an array record
(i.e., a database record)
* orderby, how to order the results
* includeindex, which, if set, will return the
original record position in the database
I have a function I use to which getbyfunction passes a
record array. It needs to compare against some values
that are in the routine from which I call
getbyfunction. The only way to do this presently is to
use globals. For example:
function callingGetByFunction($value1, $value2) {
// some manipulations...
$result = $db->getbyfunction("sortByValue");
// some more manipulations
}
function sortByValue($record) {
if (($record["value"] < $value1) &&
($record["value"] > $value2)) {
return true;
} else return false;
}
Currently, the only way I can pass $value1 and $value2
to sortByValue is to make them globals. What I propose
is to add an optional fourth argument to getbyfunction,
selectfnArgs, which is an array of arguments. If
present, selectfn would be called like:
$selectfn($record, $selectfnArgs)
Otherwise, it would be called as it currently is. If
the programmer opts to throw in arguments, s/he would
need to build the function to parse for them.
Logged In: YES
user_id=446982
I have created a patch that has been uploaded to the tracker.