mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR If the limit clause on DataObject::get() passes a SQL type of limit, modify it for SS_List::limit()
This commit is contained in:
parent
b6803f6141
commit
4f1da0a5e8
@ -2479,11 +2479,17 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*
|
*
|
||||||
* @return mixed The objects matching the filter, in the class specified by $containerClass
|
* @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: Determine if we can deprecate for 3.0.0 and use DI or something instead
|
||||||
// Todo: Make the $containerClass method redundant
|
// Todo: Make the $containerClass method redundant
|
||||||
if($containerClass != "DataList") user_error("The DataObject::get() \$containerClass argument has been deprecated", E_USER_NOTICE);
|
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);
|
if($join) $result = $result->join($join);
|
||||||
$result->setModel(DataModel::inst());
|
$result->setModel(DataModel::inst());
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user