How in PDOStatement->fetchAll use PDO::FETCH_GROUP for grouping more than one column simultaneously?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



How in PDOStatement->fetchAll use PDO::FETCH_GROUP for grouping more
than one column simultaneously?

For example

col1  col2  col3  col4
13     p1       1     boroda
13     p1       1     boroda 2
13     p1       2     boroda 3
13     p2       2     boroda 4
13     p2       2     boroda 5
14     p3       2     boroda 6
14     p4       2     boroda 7
14     p4       2     boroda 8

$data = $sth->fetchAll(PDO::FETCH_ASSOC | PDO::FETCH_GROUP, 2);

Expected result for $data:

Array
(
    [13] => Array
        (
             [p1] => Array
                   (
                         [0] => Array
                             (
                                [col3] => 1
                                [col4] => boroda
                             )
                         [1] => Array
                             (
                                [col3] => 1
                                [col4] => boroda 2
                             )
                         [2] => Array
                             (
                                [col3] => 2
                                [col4] => boroda 3
                             )
                        )
                    [p2] => Array
                        (
                         [0] => Array
                             (
                                [col3] => 2
                                [col4] => boroda 4
                             )
                         [1] => Array
                             (
                                [col3] => 2
                                [col4] => boroda 5
                             )
                   )
         )
    [14] => Array
        (
             [p3] => Array
                   (
                         [0] => Array
                             (
                                [col3] => 2
                                [col4] => boroda 6
                             )
                   )
             [p4] => Array
                   (
                         [0] => Array
                             (
                                [col3] => 2
                                [col4] => boroda 7
                             )
                         [1] => Array
                             (
                                [col3] => 2
                                [col4] => boroda 8
                             )

                   )
         )

--
Best Regards,
Mike Gavrilov.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux