-
Notifications
You must be signed in to change notification settings - Fork 120
Conversation
array_push($sqls, sprintf("LIMIT %s", $limit)); | ||
} | ||
} | ||
return; |
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 think deep if can be simplified with return early:
if (! $this->limit) {
return;
}
if ($this->offset) {
array_push($sqls, sprintf("LIMIT %s OFFSET %s", $limit, $offset));
return;
}
array_push($sqls, sprintf("LIMIT %s", $limit));
return;
// Note: db2_prepare/db2_execute fails with positional parameters, for LIMIT & OFFSET | ||
$limit = (int)$this->limit; | ||
$offset = (int)$this->offset; | ||
if ($this->limit) { |
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.
$this->limit
is not casted to (int)
one, I think should use $limit
instead
$limit = (int)$this->limit; | ||
$offset = (int)$this->offset; | ||
if ($this->limit) { | ||
if ($this->offset) { |
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 think should use if ($offset)
instead as it is the casted with (int)
one
@samsonasik Addressed. |
if ($this->supportsLimitOffset) { | ||
// Note: db2_prepare/db2_execute fails with positional parameters, for LIMIT & OFFSET | ||
$limit = (int)$this->limit; | ||
$offset = (int)$this->offset; |
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.
$offset
never used if ! $limit
, can be define later (after line 114)
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.
Just formatting, other than the formatting, everything here looks great.
@@ -82,6 +104,23 @@ protected function processLimitOffset(PlatformInterface $platform, DriverInterfa | |||
return; | |||
} | |||
|
|||
if ($this->supportsLimitOffset) { | |||
// Note: db2_prepare/db2_execute fails with positional parameters, for LIMIT & OFFSET | |||
$limit = (int)$this->limit; |
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.
space after the cast.
if ($this->supportsLimitOffset) { | ||
// Note: db2_prepare/db2_execute fails with positional parameters, for LIMIT & OFFSET | ||
$limit = (int)$this->limit; | ||
if (! $limit) { |
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 space after the !
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.
most of zf code has space after !
, I think already part of zf cs /cc @webimpress
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.
@mwillbanks
@samsonasik is right. See zendframework/zend-coding-standard#1 - Generic.Formatting.SpaceAfterNot
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.
@mwillbanks
Yes, and this is even part of current version of zend-coding-standard
(1.0.0): https://github.com/zendframework/zend-coding-standard/blob/master/ruleset.xml#L12
return; | ||
} | ||
|
||
$offset = (int)$this->offset; |
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.
space after the cast.
Just took a quick look at the code. |
Correct - ORDER BY is supported as you'd expect if you've used Zend\Db with MySQL for instance. |
@mwillbanks Requested changes are done. |
@akrabat thanks for your contribution! |
Since 2016, DB2 has supported the
LIMIT x OFFSET y
construct. This PR supports the new construct in a BC manner via a feature flag. To use with TableGateway: