Skip to content

better support for BETWEEN clause #297

Open

Description

@8ctopus

Currently BETWEEN is supported using database::literal, such as in this query:

$sql = <<<SQL
    SELECT
        *
    FROM
        test
    WHERE
SQL;

$rows = $database->query($sql, [
    $database::literal('id BETWEEN ? AND ?', 1, 2),
]);

It would be even nicer if it worked like this:

$sql = <<<SQL
    SELECT
        *
    FROM
        test
    WHERE
SQL;

$rows = $database->query($sql, [
    'id BETWEEN' => [1, 2],
]);

Now when it sees that the value is an array ([1, 2]), it automatically switches to IN.

https://github.com/nette/database/blob/master/src/Database/SqlPreprocessor.php#L285-L293)

Activity

  1. added a commit that references this issue on Apr 3, 2023
    88ed3df
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