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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
20 + 8 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 11:01:28 2024 UTC