Updates to ORM sub records and change Sort::MAsort, sortby is now an array

This commit is contained in:
Deon George
2015-09-29 15:51:56 +10:00
parent 9a41635025
commit 69c8052b53
2 changed files with 23 additions and 5 deletions

View File

@@ -19,9 +19,9 @@ abstract class lnApp_Sort {
* @param boolean Whether to reverse sort.
* @return array Sorted multi demension array.
*/
public static function MAsort(&$data,$sortby,$rev=0) {
public static function MAsort(&$data,array $sortby=array(),$rev=0) {
// if the array to sort is null
if (! $data)
if (! $data OR ! $sortby)
return;
// if the array to sort is null or empty, or our sortby is bad
# if (! preg_match('/^([a-zA-Z0-9_]+(\([a-zA-Z0-9_,]*\)(->[a-zA-Z0-9])?)?,?)+$/',$sortby) || ! $data)
@@ -29,7 +29,7 @@ abstract class lnApp_Sort {
$code = '$c=0;';
foreach (explode(',',$sortby) as $key) {
foreach ($sortby as $key) {
$code .= 'if (is_object($a) || is_object($b)) {';
foreach (array('a','b') as $x) {
$code .= 'if (is_array($'.$x.'->'.$key.')) {';