|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-07 15:05 UTC] jakoch at web dot de
Description:
------------
Hello,
this might be a bug.
I'm trying to fetch an associative array grouped by the values of a specified column. In my case the column 'name'.
How to group values by the second column ?
Expected result:
----------------
$res = $stmt->fetchALL(PDO::FETCH_COLUMN,1|PDO::FETCH_GROUP);
array
'configs' =>
array
'submodule_id' => '17' (length=2)
'name' => 'configs' (length=7)
'file_name' => 'configs.module.php' (length=18)
'class_name' => 'module_admin_configs' (length=20)
Actual result:
--------------
$res = $stmt->fetchALL(PDO::FETCH_NAMED);
Return:
array
0 =>
array
'submodule_id' => '17' (length=2)
'name' => 'configs' (length=7)
'file_name' => 'configs.module.php' (length=18)
'class_name' => 'module_admin_configs' (length=20)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 06:00:01 2025 UTC |
same here: $query="SELECT col1,col2 FROM table"; $db->query($query)->fetchAll(PDO::FETCH_COLUMN|PDO::FETCH_GROUP); result: Array ( [1] => Array ( [0] => firmaA ) [2] => Array ( [0] => firmaB ) [3] => Array ( [0] => firmaC ) [4] => Array ( [0] => firmaD ) ) expected: Array ( [1] => firmaA [2] => firmaB [3] => firmaC [4] => firmaD )