0

Как сформировать запрос в QueryBuilder'е, чтобы проверить, есть ли определенное значение в массиве в поле типа json? Делал так:

$this->createQueryBuilder('f')
            ->select('f.id, f.text, f.type, f.can_close')
            ->orderBy('f.created_at')
            ->andWhere('f.pages = :page')
            ->setParameter('page', $page)
            ->getQuery()
            ->getResult();

Выводит следующую ошибку:

An exception occurred while executing 'SELECT f0_.id AS id_0, f0_.text AS text_1, f0_.type AS type_2, f0_.can_close AS can_close_3 FROM flash_messages f0_ WHERE f0_.pages = ? ORDER BY f0_.created_at ASC' with params ["main_page"]:

SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: json = unknown LINE 1: ...n_close_3 FROM flash_messages f0_ WHERE f0_.pages = $1 ORDER... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

PostgreSQL стоит версии 9.5.17

К raw запросам не хотелось бы прибегать, если это возможно. Как можно решить мою проблему?

1 ответ 1

0

Можно использовать эту библиотеку ScientaNL / DoctrineJsonFunctions

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.