Skip to content

Query Builder getWhere Crash #2143

Closed
@entrinix

Description

@entrinix

Describe the bug
When using the Query Builder, the getWhere method crashes if no offset is given with "Argument 2 passed to CodeIgniter\Database\BaseBuilder::limit() must be of the type int, null given"

The default offset should be zero, and if an int is entered, it would use that.

CodeIgniter 4 version
BETA4

Affected module(s)
/vendor/codeigniter4/framework/system/Database/BaseBuilder.php line 1612

Expected behavior, and steps to reproduce if appropriate
->getWhere([
'email' => $email,
], 1);

will crash

->getWhere([
'email' => $email,
], 1, 0);

will run as expected.

Suggest changing line 1603 of /vendor/codeigniter4/framework/system/Database/BaseBuilder.php

from

public function getWhere($where = null, int $limit = null, int $offset = null)

to

public function getWhere($where = null, int $limit = null, int $offset = 0)

Context

  • PHP version 7.3.8

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions