Commit 85185bdff14218c59abf271d87427a4f77f600e0

Authored by nbm
1 parent 0c2ca685

Support an orderby option


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3517 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing 1 changed file with 7 additions and 0 deletions
lib/ktentity.inc
@@ -226,6 +226,9 @@ class KTEntityUtil { @@ -226,6 +226,9 @@ class KTEntityUtil {
226 } 226 }
227 227
228 function &getList($sTable, $sClassName, $sWhereClause = null, $aOptions = null) { 228 function &getList($sTable, $sClassName, $sWhereClause = null, $aOptions = null) {
  229 + if (is_null($aOptions)) {
  230 + $aOptions = array();
  231 + }
229 $bIDs = false; 232 $bIDs = false;
230 $sIDField = 'id'; 233 $sIDField = 'id';
231 if (is_array($aOptions)) { 234 if (is_array($aOptions)) {
@@ -254,6 +257,10 @@ class KTEntityUtil { @@ -254,6 +257,10 @@ class KTEntityUtil {
254 return new PEAR_Error('Weird WhereClause passed'); 257 return new PEAR_Error('Weird WhereClause passed');
255 } 258 }
256 } 259 }
  260 + $sOrderBy = KTUtil::arrayGet($aOptions, 'orderby');
  261 + if (!empty($sOrderBy)) {
  262 + $sQuery .= "ORDER BY " . $sOrderBy;
  263 + }
257 $aIDs = DBUtil::getResultArrayKey(array($sQuery, $aParams), $sIDField); 264 $aIDs = DBUtil::getResultArrayKey(array($sQuery, $aParams), $sIDField);
258 265
259 if ($bIDs === true) { 266 if ($bIDs === true) {