>
> Hi,
>
> What would "support" exactly mean for a JSON type? Since JSON is a way of serialising data into a string, wouldn't all JSON values going into and out of the database just look like strings to the driver?
>
> For Postgres's array types, some support for serialising and unserialising would definitely be useful, though, because the format is rather complex, particularly if you have multidimensional and sparse arrays. Obviously, users now have the workaround of transferring as JSON, but I know my last company had a pair of utility functions to attempt this in userland, which were known to be buggy in certain edge cases.
>
> Regards,
>

JSON should be automatically converted to proper type(s).

$data = ['name' => 'John'];
$sth = $dbh->prepare('INSERT INTO table (json_column) values (:data)');
$sth->bindParam(':data', $data, PDO::PARAM_JSON); // new parameter


SELECT json_column FROM table;
$stmt->fetch(PDO::FETCH_ASSOC) should return

array(
    [json_column] => array('name' => 'John')
)
.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to