I have MySQL 5.7 and a query with PDO: But after it I’m having: id data 1 {“old_field”: 2, “new_field”: “1”} Why does my new value have a string type? Expected table: id data 1 {“old_field”: 2, “new_field”: 1} I have success without using PDO(JSON_OBJECT(‘new_field’, 1)), but I have a string type with using placeholders. Answer When you pass an
Tag: mysql-json
How to search through unknown property name in database with Laravel
I’m trying to search database with json contains method of laravel. Here is my JSON of one database line: I want to search ID, but as you see there are numbers as properties. In example I want to find 11023235667. I’ve tried it like that: But it didn’t worked. How can I do it? EDIT: I have also tried this:
Backslash in json_encode (PHP) + JSON_ARRAYAGG (mySQL)
The problem is the backslashes with the quotes in the array colors. I think it’s because the JSON_ARRAYAGG but I don’t know how to print a correct json. Query: PHP: OUTPUT: Answer You are encoding colors twice. First in SQL and then in PHP. What you can do is either decode colors in PHP before you encode $data: If you