Re: [PHP-DEV] PDO native JSON / array support

2017-07-27 Thread Philip Hofstetter
Hi, I few years ago, I did a throwaway implementation for this for reading: https://github.com/pilif/php-src/tree/pdo_pgsql-improvements This supports columns of type jsonb, json and text[] and I was considering also adding support for the various timestamps, date and so on. Generally, interest

Re: [PHP-DEV] PDO native JSON / array support

2017-07-27 Thread Johannes Schlüter
On Do, 2017-07-27 at 08:14 +0200, Michał wrote: > Encoding data to insert query is simple. But selecting data requires  > additional magic and processing. The magic while reading is quite limited - at least for MySQL the protocol contains a flag in the meta data telling whether a field is a "arbit

Re: [PHP-DEV] PDO native JSON / array support

2017-07-26 Thread Michał
Encoding data to insert query is simple. But selecting data requires additional magic and processing. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] PDO native JSON / array support

2017-07-26 Thread Rowan Collins
On 26 July 2017 14:02:03 BST, "Michał" wrote: >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_colu

Re: [PHP-DEV] PDO native JSON / array support

2017-07-26 Thread Johannes Schlüter
On Mi, 2017-07-26 at 15:02 +0200, Michał wrote: > > 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 > > > SE

Re: [PHP-DEV] PDO native JSON / array support

2017-07-26 Thread Michał
> > 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

Re: [PHP-DEV] PDO native JSON / array support

2017-07-26 Thread Rowan Collins
On 26 July 2017 11:25:00 BST, "Michał" wrote: >Most database systems have now native support for JSON format. Some of >them, like PostgreSQL, also accepts arrays. I rememeber there was some >fork of pgsql extension with native array support. > >Maybe it is time to extend PDO so it can accept at