diff --git a/src/QueryBuilder.php b/src/QueryBuilder.php index 9639964..afb5d80 100644 --- a/src/QueryBuilder.php +++ b/src/QueryBuilder.php @@ -131,10 +131,10 @@ public function query($sql, $params = [], $page = null, $perPage = 20) { if (!is_null($page)) { $page = (int) $page; - if ($page < 0) { - $page = 0; + if ($page < 1) { + $page = 1; } - $offset = $perPage * $page; + $offset = $perPage * ($page - 1); $limit = $perPage; $sql .= " LIMIT {$limit} OFFSET {$offset}"; @@ -229,7 +229,6 @@ protected function generateCallback() implode(' : ', $stmt->errorInfo()) ); } - if ('select' !== strtolower(substr($sql, 0, 6))) { return $result; }