Re: How in PDOStatement->fetchAll use PDO::FETCH_GROUP for grouping more than one column simultaneously?
| From: | Gerardo Benitez | Date: | Wed, 11 May 2011 12:38:48 +0000 |
| Subject: | Re: How in PDOStatement->fetchAll use PDO::FETCH_GROUP for grouping more than one column simultaneously? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-312758@lists.php.net to get a copy of this message | ||
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@gmail.com> 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