fix: $offset not set when passing integer to $limit in limit() (#50)

This PR just sets the `OFFSET` value to `0` if no offset is provided for all calls to `limit()`. This fixes a bug where no `OFFSET` was set if the `$limit` parameter was given an integer.. which was the only allowed type except null anyways.

Reviewed-on: https://codeberg.org/vlw/php-mysql/pulls/50
This commit is contained in:
Victor Westerlund 2025-07-17 11:09:02 +02:00
parent e062930c41
commit c6ef93dbdb

View file

@ -163,17 +163,8 @@
return $this; return $this;
} }
// Set LIMIT without range directly as integer // Coerce offset to zero if no offset is defined
if (is_int($limit)) { $offset = $offset ?? 0;
$this->limit = $limit;
return $this;
}
// No offset defined, set limit property directly as string
if (is_null($offset)) {
$this->limit = (string) $limit;
return $this;
}
// Set limit and offset as SQL CSV // Set limit and offset as SQL CSV
$this->limit = "{$offset},{$limit}"; $this->limit = "{$offset},{$limit}";