/** * Render LIMIT OFFSET clause * * @param string $sql SQL query * @return string */ protected function renderLimitoffset($sql) { $count = 0; $offset = 0; if (!empty($this->parts[self::LIMIT_OFFSET])) { $offset = (int) $this->parts[self::LIMIT_OFFSET]; $count = PHP_INT_MAX; } if (!empty($this->parts[self::LIMIT_COUNT])) { $count = (int) $this->parts[self::LIMIT_COUNT]; } /* * Add limits clause */ if ($count > 0) { $sql = trim($this->adapter->limit($sql, $count, $offset)); } return $sql; }
/** * @expectedException \Dewdrop\Exception */ public function testInvalidLimitOffsetThrowsException() { $this->db->limit('SELECT * FROM dewdrop_test_fruits', 1, -10); }