I'm using MySQL 5.7.19
I'm trying to retrieve a class that looks as follows
class Task
{
public $title;
public $done;
}
the title
and done
properties are saved in a JSON column.
The code that I use to retrieve looks as follows:
$tasksSql = <<<'EOT'
SELECT JSON_UNQUOTE(JSON_EXTRACT(data, '$.title')) AS title,
JSON_EXTRACT(data, '$.done') AS done
FROM Tasks WHERE TaskListId = ?;
EOT;
$tasksStatement = $connection->prepare($tasksSql);
$tasksStatement->execute([$id]);
$tasksStatement->setFetchMode(PDO::FETCH_CLASS, "Task");
$taskList->tasks = $tasksStatement->fetchAll(PDO::FETCH_CLASS, "Task");
It fills out all the fields, but the done
property gets set the string values "true" or "false" instead of a boolean value.