Re: PDO native JSON / array support

From: Date: Thu, 27 Jul 2017 10:27:29 +0000
Subject: Re: PDO native JSON / array support
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-100058@lists.php.net to get a copy of this message
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 "arbitrary" string field or a JSON field, based on that one could decode accordingly. The question is what the user expects ... One fact is that applications are already using those types, changing the default behavior would be a break. Also some users might want to just pass it to a JS frontend and decoding and renencding for the transport is a wast of cpu cycles. Similar more "administrative" applications like phpMyAdmin need exta handling as the value can'T be printed simply anymore. Thus we'd need a special flag like     $pdo->fetch(PDO::FETCH_ASSOC | PDO::FETCH_DECODE_JSON) and from there there is little step for leaving this completely to the user ... they know what they need. johannes

« previous php.internals (#100058) next »