protected function getLimitSql($limit, array $pageItem = [])
    {
        $limitSql = '';
        if (!empty($limit) || !empty($pageItem)) {
            $limitSql = 'LIMIT ';
            if (!empty($pageItem)) {
                list($pageNo, $rowsPerPage) = $pageItem;

                $pageNo = (int) $pageNo;
                if ($pageNo < 1) {
                    throw new \InvalidArgumentException("Invalid pagination page number \"{$pageNo}\"");
                }
                $rowsPerPage = (int) $rowsPerPage;

                // Offset example: "10" skips the first 10 rows, start showing the 11th
                $offset = ($pageNo - 1) * $rowsPerPage;
                $limitSql .= sprintf('%d, %d', $offset, $rowsPerPage);
            } else {
                $limitSql .= (int) $limit;
            }
        }

        return $limitSql;
    }