Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100047 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26415 invoked from network); 26 Jul 2017 13:02:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jul 2017 13:02:09 -0000 X-Host-Fingerprint: 89.231.48.169 host-89-231-48-169.dynamic.mm.pl Received: from [89.231.48.169] ([89.231.48.169:14051] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 84/D6-49004-EC298795 for ; Wed, 26 Jul 2017 09:02:08 -0400 Message-ID: <84.D6.49004.EC298795@pb1.pair.com> To: internals@lists.php.net References: <6B.63.49004.FFD68795@pb1.pair.com> Date: Wed, 26 Jul 2017 15:02:03 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: pl Content-Transfer-Encoding: 7bit X-Posted-By: 89.231.48.169 Subject: Re: [PHP-DEV] PDO native JSON / array support From: aaatoja@o2.pl (=?UTF-8?Q?Micha=c5=82?=) > > 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') ) .