This is likely to be a simple error on my part but I've been trying to sort a dataobject (using CategoryPage's Title column) alphabetically using the following:
function TopCategories() {
$filter = 'isTopCategory = 1';
$sort = 'Title DESC';
$num=10;
$categories = DataObject::get('CategoryPage',$filter,$sort,'',$num);
return $categories;
}
But when ever i use a sort statement I get the following error:
FATAL ERROR: DATABASE ERROR: .... Column 'Title' in order clause is ambiguous ...
I've also tried the following:
function TopCategories() {
$filter = 'isTopCategory = 1';
$sort = "'CategoryPage'.Title DESC";
$num=10;
$categories = DataObject::get('CategoryPage',$filter,$sort,'',$num);
return $categories;
}
but again this returns an error:
FATAL ERROR: DATABASE ERROR: ... You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.Title DESC LIMIT 10' at line 1
Can anyone help with this issue?