Mysql 5.7.9 JSON type with Doctrine DQL

时间:2016-04-15 11:04:17

标签: php mysql json symfony doctrine-orm

anybody try to work with doctrine dql and MySQL JSON type?

I trying to build equal sql

SELECT o0_.id AS id_0, ..., o0_.json AS json_6 
FROM ...  
ORDER BY o0_.json->"$.index" DESC LIMIT 10;

I mean this part:

ORDER BY o0_.json->"$.index" DESC

For that i wrote this code

// MySQL 5.7.9 JSON features
$queryBuilder->addOrderBy('o.json->"$.' . $column . '"', mb_strtolower($value) == 'desc' ? 'DESC' : 'ASC');

and get exception

[Syntax Error] line 0, col 210: Error: Expected Literal, got '>'

Anybody have ideas how to solve this problem?

0 个答案:

没有答案