Commit d399e611d65d637cc53574aa81cb01fb108b1cca
1 parent
9ab04258
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 | 226 | } |
| 227 | 227 | |
| 228 | 228 | function &getList($sTable, $sClassName, $sWhereClause = null, $aOptions = null) { |
| 229 | + if (is_null($aOptions)) { | |
| 230 | + $aOptions = array(); | |
| 231 | + } | |
| 229 | 232 | $bIDs = false; |
| 230 | 233 | $sIDField = 'id'; |
| 231 | 234 | if (is_array($aOptions)) { |
| ... | ... | @@ -254,6 +257,10 @@ class KTEntityUtil { |
| 254 | 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 | 264 | $aIDs = DBUtil::getResultArrayKey(array($sQuery, $aParams), $sIDField); |
| 258 | 265 | |
| 259 | 266 | if ($bIDs === true) { | ... | ... |