-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selection::resetOrder #54
base: master
Are you sure you want to change the base?
Conversation
@@ -14,12 +14,29 @@ Nette\Database\Helpers::loadFromFile($connection, __DIR__ . "/../files/{$driverN | |||
|
|||
test(function() use ($context) { | |||
$apps = array(); | |||
foreach ($context->table('book')->where('title LIKE ?', '%t%')->order('title')->limit(3) as $book) { // SELECT * FROM `book` WHERE (`title` LIKE ?) ORDER BY `title` LIMIT 3 | |||
|
|||
$selection = $context->table('book')->where('title LIKE ?', '%t%')->order('title DESC')->limit(3); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added also DESC
keyword to previous test because without it result was the same as defined order in SQL fixture.
I never had strong opinition, how many methods should be reflected in selection. |
public function resetOrder() | ||
{ | ||
$this->emptyResultSet(); | ||
call_user_func_array(array($this->sqlBuilder, 'setOrder'), [[], []]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for call_user_func_, $this->sqlBuilder->setOrder([], []); is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanx. Why not call it directly if it has no magical arguments. Copy & Paste of ::order
:(
@hrach It failing on PHP 5.3 - this version is no longer supported? |
5.3 is failing, because it doesn't support the [] array syntax |
@redwormik Thx, I'm stupid or blind. |
0fc7ac2
to
7194522
Compare
6c43c50
to
6690dde
Compare
In some cases it would be nice to have an option reset current order on the query.
I see that corresponding method ::setOrder is present in SqlBuilder since v2.3 but it's not used in Selection.
So I've added option for
ORDER BY
clause reset.What do you think about that?