php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #75486 Additional PDO::FETCH_GROUP combinations
Submitted: 2017-11-05 17:46 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: andrew at fw dot net dot nz Assigned:
Status: Open Package: PDO related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: andrew at fw dot net dot nz
New email:
PHP Version: OS:

 

 [2017-11-05 17:46 UTC] andrew at fw dot net dot nz
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).



Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 16:01:33 2024 UTC