Re: [PHP] How in PDOStatement-fetchAll use PDO::FETCH_GROUP for grouping more than one column simultaneously?

2011-05-11 Thread Gerardo Benitez
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.gavri...@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


Re: [PHP] How in PDOStatement-fetchAll use PDO::FETCH_GROUP for grouping more than one column simultaneously?

2011-05-11 Thread Михаил Гаврилов
Hi Gerardo.

Of course I can make grouping array by using PHP functions, but if
function fetchAll with parameter PDO::FETCH_GROUP  will be have this
feature. The described variant will be more clean and beautiful.

--
Best Regards,
Mike Gavrilov.

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