[Piwik-hackers] API returning multiple arrays

Matthieu Aubry matthieu.aubry at gmail.com
Wed Jun 4 02:49:27 CEST 2008


In the future please post new message for new questions.

For what you're trying to do I would return a Piwik_DataTable_Array. 
Have a look at modules/DataTable/Array.php


Anton Andrievskij wrote:
> Hi, Matt.
>
> I have added new method to VisitsSummary/API.php. The method is 
> getMultipleSites() which is the same as get() but for multiple idSite 
> values.
>
> I want it to return array of values which get() returns.
>
> In other words, I want it to return the array of arrays like this:
>
> Array
> (
>     [max_actions] => 0
>     [nb_uniq_visitors] => 0
>     [nb_visits] => 0
>
>     [nb_actions] => 0
>     [sum_visit_length] => 0
>     [bounce_count] => 0
> )
>
> But if I do "foreach $idSites as $idSite" and then join array like 
> bigResult[] = get($idSite), I get the answer from API with rubbish:
>
> Array
> (
>     [0] => Array
>         (
>             [0] => __PHP_Incomplete_Class Object
>                 (
>                     [__PHP_Incomplete_Class_Name] => Piwik_DataTable_Simple
>
>                     [rows:protected] => Array
>                         (
>                             [0] => __PHP_Incomplete_Class Object
>                                 (
>                                     [__PHP_Incomplete_Class_Name] => Piwik_DataTable_Row
>
>                                     [c] => Array
>                                         (
>                                             [0] => Array
>                                                 (
>                                                     [label] => max_actions
>
>                                                     [value] => 0
>                                                 )
>
>                                             [1] => Array
>                                                 (
>
>                                                 )
>
>                                             [3] => 
>                                         )
>
>                                 )
>
>                             [1] => __PHP_Incomplete_Class Object
>
>                                 (
>                                     [__PHP_Incomplete_Class_Name] => Piwik_DataTable_Row
>                                     [c] => Array
>                                         (
>
>                                             [0] => Array
>                                                 (
>                                                     [label] => nb_uniq_visitors
>                                                     [value] => 0
>
>                                                 )
>
>                                             [1] => Array
>                                                 (
>                                                 )
>
>
>                                             [3] => 
>                                         )
>
>                                 ) 
> ... etc....
> .... etc...
>
> asdf
>   
>
> What Piwik funcion have I to use to convert this result to something 
> beautiful like exmple below?
>
> Aarray( [0] =>
> Array
> (
>     [max_actions] => 0
>     [nb_uniq_visitors] => 0
>     [nb_visits] => 0
>     [nb_actions] => 0
>
>     [sum_visit_length] => 0
>     [bounce_count] => 0
> ),
> [1] =>
> Array
> (
>     [max_actions] => 0
>     [nb_uniq_visitors] => 0
>     [nb_visits] => 0
>     [nb_actions] => 0
>     [sum_visit_length] => 0
>
>     [bounce_count] => 0
> )
>
> .... etc etc etc.....
>
> On Tue, Jun 3, 2008 at 12:48 PM, Anton Andrievskij <x.meglio at gmail.com 
> <mailto:x.meglio at gmail.com>> wrote:
>
>     ha-ha, Matt, I see your position.
>
>     Ok. but sorry I have not time to make patches right now. I only
>     wanted to say that there are many users that wan't research for
>     bugs. They want Piwik working and they want quick answers to their
>     questions.
>
>     Anton
>
>
>     On Tue, Jun 3, 2008 at 12:45 PM, Matthieu Aubry
>     <matthieu.aubry at gmail.com <mailto:matthieu.aubry at gmail.com>> wrote:
>
>         Anton,
>         Users are always happy to help us solve more bugs. I don't
>         have concerns about it, as I've worked on open source projects
>         for the last few years and always had great help from the
>         community.
>
>         I'm asking for details because this is an unknown bug,
>         something I've never heard of before.
>
>         If you're smart enough to guess what the problem is without
>         details, please send us a patch, that would be lovely!
>
>         Matt
>
>
>
>         On Tue, Jun 3, 2008 at 10:40 AM, Anton Andrievskij
>         <x.meglio at gmail.com <mailto:x.meglio at gmail.com>> wrote:
>
>             Matthieu. I advice you to be more "friendly" with Piwik users.
>
>             If someone reporting a bug - do not ask him to make full
>             research on bug and even to put it to bugs in Trac. You
>             are getting feedback from users - it's all - and you have
>             to thank them for this. If you ask users to research for
>             each bug - they will not love Piwik. That is true. They
>             need feedback and answers, they do not want to make
>             research for your project. You can't get every users
>             working on your project as tester and/or developer. It is
>             wrong approach.
>
>             Probably this will help you to egrow Piwik community
>             faster. Your Piwiki must be very easy to use and
>             self-controlled with bugs etc. If user can't run it
>             without your help or without asking you something - than
>             installation is not good.
>
>             Thanks,
>             Anton
>
>
>             On Tue, Jun 3, 2008 at 12:33 PM, Matthieu Aubry
>             <matthieu.aubry at gmail.com
>             <mailto:matthieu.aubry at gmail.com>> wrote:
>
>                 Have you tried with other browsers? Can you see some
>                 javascript errors?  Have you checked your apache error
>                 log?
>
>                 On Tue, Jun 3, 2008 at 12:01 AM, skunkwerk
>                 <skunkwerk at gmail.com <mailto:skunkwerk at gmail.com>> wrote:
>
>                     first, looks like a great project.
>                     i installed it smoothly and added the javascript
>                     to my site.  i checked in the database and there
>                     was a new entry for my visit, but when i go to
>                     piwik and click on any of the tabs all i see is
>                     'loading data' and it never loads anything.  any
>                     idea why this might be?
>
>                     thanks,
>                     imran
>
>                     _______________________________________________
>                     Piwik-hackers mailing list
>                     Piwik-hackers at piwik.org
>                     <mailto:Piwik-hackers at piwik.org>
>                     http://lists.piwik.org/cgi-bin/mailman/listinfo/piwik-hackers
>
>
>
>                 _______________________________________________
>                 Piwik-hackers mailing list
>                 Piwik-hackers at piwik.org <mailto:Piwik-hackers at piwik.org>
>                 http://lists.piwik.org/cgi-bin/mailman/listinfo/piwik-hackers
>
>
>
>
>             -- 
>             Best regards,
>             Anton Andriyevskyy
>
>             Please think about the environment
>             and do not print this e-mail
>             unless you really need to.
>             _______________________________________________
>             Piwik-hackers mailing list
>             Piwik-hackers at piwik.org <mailto:Piwik-hackers at piwik.org>
>             http://lists.piwik.org/cgi-bin/mailman/listinfo/piwik-hackers
>
>
>
>         _______________________________________________
>         Piwik-hackers mailing list
>         Piwik-hackers at piwik.org <mailto:Piwik-hackers at piwik.org>
>         http://lists.piwik.org/cgi-bin/mailman/listinfo/piwik-hackers
>
>
>
>
>     -- 
>     Best regards,
>     Anton Andriyevskyy
>
>     Please think about the environment
>     and do not print this e-mail
>     unless you really need to.
>
>
>
>
> -- 
> Best regards,
> Anton Andriyevskyy
>
> Please think about the environment
> and do not print this e-mail
> unless you really need to.
> ------------------------------------------------------------------------
>
> _______________________________________________
> Piwik-hackers mailing list
> Piwik-hackers at piwik.org
> http://lists.piwik.org/cgi-bin/mailman/listinfo/piwik-hackers
>   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.piwik.org/pipermail/piwik-hackers/attachments/20080604/97ee1ff7/attachment.htm 


More information about the Piwik-hackers mailing list