Home    Articles


Zend Framework 2 Select with Limit () thorws error


This is a very weird issue becouse ZF2 is launched for a while already.

I'm not sure why they couldn't fix this so far. But here is the reason for this error.

In Zend/Db library more exactly on this path: "Zend/Db/Sql/Select.php" there are 2 methods "processLimit","processOffset". In those methods you can see that is returned a quoted value of your integer.

protected function processLimit(PlatformInterface $platform, DriverInterface $driver = null, ParameterContainer $parameterContainer = null)
        if ($this->limit === null) {
        if ($parameterContainer) {
            $parameterContainer->offsetSet('limit', $this->limit, ParameterContainer::TYPE_INTEGER);
            return array($driver->formatParameterName('limit'));
      return array($platform->quoteValue($this->limit));

All you have to do is to change:

return array($platform->quoteValue($this->limit));


return array(intval($this->limit)); // intaval for security reasons.

And yeah...you have to change the library.