mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Supporting full parameter signature in Versioned->Versions(), allVersions()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@86216 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
3386e8223a
commit
d834223142
@ -506,20 +506,20 @@ class Versioned extends DataObjectDecorator {
|
|||||||
return !$stagesAreEqual;
|
return !$stagesAreEqual;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Versions($filter = "") {
|
function Versions($filter = "", $sort = "", $limit = "", $join = "", $having = "") {
|
||||||
return $this->allVersions($filter);
|
return $this->allVersions($filter, $sort, $limit, $join, $having);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a list of all the versions available.
|
* Return a list of all the versions available.
|
||||||
* @param string $filter
|
* @param string $filter
|
||||||
*/
|
*/
|
||||||
function allVersions($filter = "") {
|
function allVersions($filter = "", $sort = "", $limit = "", $join = "", $having = "") {
|
||||||
$query = $this->owner->extendedSQL($filter,"");
|
$query = $this->owner->extendedSQL($filter, $sort, $limit, $join, $having);
|
||||||
|
|
||||||
foreach($query->from as $table => $join) {
|
foreach($query->from as $table => $tableJoin) {
|
||||||
if($join[0] == '"') $baseTable = str_replace('"','',$join);
|
if($tableJoin[0] == '"') $baseTable = str_replace('"','',$tableJoin);
|
||||||
else if (substr($join,0,5) != 'INNER') $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$table\".\"Version\" = \"{$baseTable}_versions\".\"Version\"";
|
else if (substr($tableJoin,0,5) != 'INNER') $query->from[$table] = "LEFT JOIN \"$table\" ON \"$table\".\"RecordID\" = \"{$baseTable}_versions\".\"RecordID\" AND \"$table\".\"Version\" = \"{$baseTable}_versions\".\"Version\"";
|
||||||
$query->renameTable($table, $table . '_versions');
|
$query->renameTable($table, $table . '_versions');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +529,7 @@ class Versioned extends DataObjectDecorator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$query->where[] = "\"{$baseTable}_versions\".\"RecordID\" = '{$this->owner->ID}'";
|
$query->where[] = "\"{$baseTable}_versions\".\"RecordID\" = '{$this->owner->ID}'";
|
||||||
$query->orderby = "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC";
|
$query->orderby = ($sort) ? $sort : "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC";
|
||||||
|
|
||||||
|
|
||||||
$records = $query->execute();
|
$records = $query->execute();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user