|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests |
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 18:00:02 2025 UTC |
Description: ------------ Two proposed PDO fetch combinations I think would be sensible (I've actually tried to use these on occasion, assuming they would work). --- 1. PDO::FETCH_GROUP | PDO::FETCH_KEY_PAIR Same as FETCH_KEY_PAIR but organised into groups. The first column would be the group, the second the key and the third the value. E.g.: [ 'group1'=>[ 'key1'=>'val1', 'key2'=>'val2' ], 'group2'=>[ ... ] ] Currently this combination appears to ignore FETCH_GROUP and gives identical results as FETCH_KEY_PAIR by itself, despite the documentation for FETCH_GROUP indicating that it can be combined with FETCH_KEY_PAIR. See also https://bugs.php.net/bug.php?id=63813. --- 2. PDO::FETCH_GROUP | PDO::FETCH_UNIQUE Same as FETCH_UNIQUE but organised into groups. The first column would be the group, the second the unique key. E.g.: [ 'group1'=>[ 'key1'=>['col3'=>'val', 'col4'=>'val', ...], 'key2'=>['col3'=>'val', 'col4'=>'val', ...] ], 'group2'=>[ ... ] ] Currently this combination appears to ignore FETCH_GROUP and gives identical results as FETCH_UNIQUE by itself, as PDO::FETCH_GROUP|PDO::FETCH_UNIQUE === PDO::FETCH_UNIQUE. --- There may be BC issues with implementing these if people are currently using these combinations believing they are achieving something (https://stackoverflow.com/a/22063422).