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 ddcd8a2961

View file

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