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

Проблема с Query Prepared Statement #1086

Open
olddeda opened this issue Feb 24, 2024 · 0 comments
Open

Проблема с Query Prepared Statement #1086

olddeda opened this issue Feb 24, 2024 · 0 comments
Assignees
Labels
Bug Help wanted Contributors, your turn to help us!

Comments

@olddeda
Copy link

olddeda commented Feb 24, 2024

Description

Пытаюсь в условие добавить конструкцию

AND "game_users"."created_at" >= NOW() - INTERVAL '3600' SECOND

How To Reproduce

1 вариант

Код

'created_at' => [
    '>=' => new Fragment("NOW() - INTERVAL '?' SECOND", $this->gameConfig->getLifetime())
],

Генерируемый SQL

AND "game_users"."created_at" >= NOW() - INTERVAL '?' SECOND

Ошибка

[2024-02-19T16:54:25.836901+00:00] ALERT: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined []

2 вариант

Код

'created_at' => [
    '>=' => new Fragment("NOW() - INTERVAL ? SECOND", $this->gameConfig->getLifetime())
],

Генерируемый SQL

AND "game_users"."created_at" >= NOW() - INTERVAL 3600 SECOND

Ошибка

SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "$6"\nLINE 7: ...AND "game_users"."created_at" >= NOW() - INTERVAL $6 SECOND ...\n  

3 вариант

Код

'created_at' => [
    '>=' => new Fragment("NOW() - INTERVAL ? SECOND", (string)$this->gameConfig->getLifetime())
],

Генерируемый SQL

AND "game_users"."created_at" >= NOW() - INTERVAL '3600' SECOND 

Ошибка

[2024-02-19T16:58:48.795321+00:00] ALERT: SQLSTATE[42601]: Syntax error: 7 ERROR:  syntax error at or near "$6" LINE 7: ...AND "game_users"."created_at" >= NOW() - INTERVAL $6 SECOND ... 

Additional Info

Q A
Framework Version 3.11.1
Cycle bridge 2.9.0
PHP version 8.3.1
PostgreSQL 16
Operating system macOS Sonoma 14.2
@olddeda olddeda added the Bug label Feb 24, 2024
@butschster butschster added the Help wanted Contributors, your turn to help us! label Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Help wanted Contributors, your turn to help us!
Projects
None yet
Development

No branches or pull requests

4 participants