I have a DataObject
with a default sort:
class Author extends DataObject {
private static $db = array('Name' => 'Varchar');
private static $default_sort = 'Name ASC';
}
I want to Author::get()
the data but with no sort.
so given...
Author::create(array('Name' => 'DEF'))->write();
Author::create(array('Name' => 'ABC'))->write();
This would output ABC then DEF using the sort, but if the sort was cleared I'd expect DEF then ABC.
I've tried Author::get()->sort('')
and Author::get()->sort(null)
but both return ABC then DEF again.
Note The reason I'm asking is that I have a complex query (using joins) where this is causing an issue and I'm getting an error with it if I try and set the sort too.
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 'ORDER BY "_SortColumn0" ASC' at line 1
So the solution, and what I'd like to know anyway, is how to clear the default sort for the specific Author::get()
while keeping the existing default sort on the DataObject
?
private static $default_sort = 'Name DESC';
– Autotransformer->sort(null)
? I haven't tested this. – Alyose->sort(null)
should really unset the sort - would you like to open an issue (or even PR) on GitHub for this? – Twinscrew