Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR If the limit clause on DataObject::get() passes a SQL type of l…

…imit, modify it for SS_List::limit()
  • Loading branch information...
commit 4f1da0a5e8176fcb2caae7612f31961fd1fb127a 1 parent b6803f6
@stojg stojg authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 model/DataObject.php
View
10 model/DataObject.php
@@ -2479,11 +2479,17 @@ public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){
*
* @return mixed The objects matching the filter, in the class specified by $containerClass
*/
- public static function get($callerClass, $filter = "", $sort = "", $join = "", $limit = "", $containerClass = "DataList") {
+ public static function get($callerClass, $filter = "", $sort = "", $join = "", $limit = null, $containerClass = "DataList") {
// Todo: Determine if we can deprecate for 3.0.0 and use DI or something instead
// Todo: Make the $containerClass method redundant
if($containerClass != "DataList") user_error("The DataObject::get() \$containerClass argument has been deprecated", E_USER_NOTICE);
- $result = DataList::create($callerClass)->where($filter)->sort($sort)->limit($limit);
+ $result = DataList::create($callerClass)->where($filter)->sort($sort);
+ if($limit && strpos($limit, ',') !== false) {
+ $limitArguments = explode(',', $limit);
+ $result->limit($limitArguments[1],$limitArguments[0]);
+ } elseif($limit) {
+ $result->limit($limit);
+ }
if($join) $result = $result->join($join);
$result->setModel(DataModel::inst());
return $result;
Please sign in to comment.
Something went wrong with that request. Please try again.