-
Notifications
You must be signed in to change notification settings - Fork 14
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
Get a value in JSON #9
Comments
And the stored data is a JSON string, not an array, so i can't search on it. |
@QuentinCurtet Have you set up the Bundle as described in the documentation and defined it as jsonb. So this should make the column JSONB. Have a look in the tests for a sample setup. Debug the query from Doctrine to see the raw sql and check if that is correct or not. Basically everything should work as described in the docs. |
Hello, Thanks for your answer. I'll look in the tests the setup, and if i don't find anything, i'll be back ^^ |
My code seems OK :
}` And in my repository :
}` But the result is empty. Some help ? |
The problem is caused by the json_encode of the json_array type that add some double quotes and backslashes and when the json is decoded, it's not an array... |
I fix the problem by creating my own type by creating JsonB type which extends type and doesn't use json_encode when inserting data. |
Perfect, not sure why you were the first to report this problem, it seems it works for most people :/. Anyway, nice fix. |
In fact, i think this was the JSON i tried to insert in my DB.
Thanks for your help it helped me :) |
Hi,
I wanted to know how i can get a value in JSON like : SELECT * FROM products WHERE (data->>'in_stock')::integer > 0;
For the moment i have this, but the result of query is empty :
$rsm = new ResultSetMapping();
$query = $this->_em->createNativeQuery("SELECT p.attributes FROM Product p WHERE (p.attributes->>'price')::float > ?;", $rsm);
$query->setParameter(1, 9);
$result = $query->getResult();
Thanks.
The text was updated successfully, but these errors were encountered: