Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better support for BETWEEN clause #297

Open
8ctopus opened this issue Apr 3, 2023 · 0 comments
Open

better support for BETWEEN clause #297

8ctopus opened this issue Apr 3, 2023 · 0 comments

Comments

@8ctopus
Copy link

8ctopus commented Apr 3, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant