Re: 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]

 



Hi Mikhail,

I think FETCH_GROUP not work in these way, anyway, do you need work with
arrays? you can do the same with a simple record, i think...

Gerardo.




On Tue, May 10, 2011 at 5:03 PM, ÐÐÑÐÐÐ ÐÐÐÑÐÐÐÐ <
mikhail.v.gavrilov@xxxxxxxxx> wrote:

> 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
>
>


-- 
Gerardo Benitez
-------------------------
www.webseficientes.com.ar
DiseÃo web, programaciÃn, Seo

[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