Being a bit more specific here regarding Question 3:

This would get accomplished using something like this in rails:

respond_to do |format|
  format.html
  format.xml  { render :xml => @user }
end

As can be seen from the lines above, the xml is being rendered right
from within the controller without having to go to the view or make
that variable available in the there.

I don't mind having to use the view, just curious if I could bypass it
completely since as I have previously mentioned I am using all
ajax/javascript in my front-end.

Thanks in advance,

Alfredo


On Sun, Feb 8, 2009 at 10:47 AM, Alfredo Quiroga-Villamil
<laww...@gmail.com> wrote:
> I have the following query:
>
> ===============================================
>            $aParams = array(
>                'fields' => array(
>                    "ifnull(CcCall.destination, 'Total')    as destination"
>                    ,'sec_to_time(sum(CcCall.sessiontime))  as duration'
>                    ,'truncate(sum(CcCall.sessionbill), 2)  as charged'
>                )
>                ,'conditions' => $aConditions
>                ,'group' => 'CcCall.destination with rollup'
>                ,'limit' => 1
>            );
>
> $aDestinationSummary = $this->CcCall->find('all', $aParams);
> ===============================================
>
> which returns data as follows:
>
> ===============================================
> 2009-02-07 23:52:19 Debug: Array
> (
>    [0] => Array
>        (
>            [0] => Array
>                (
>                    [destination] => algeria cellular algerie telecom
>                    [duration] => 00:01:30
>                    [charged] => 0.51
>                )
>
>        )
>
> )
> ===============================================
>
> Typically I would use Set::extract to extract the data I want and
> format it to json to be rendered by the view. However, in this
> particular case, the data is returned in such a way that doesn't at
> least at first glance allow me to use Set::extract.
>
> Questions:
>
> 1- Is there a way to format the query above in such a way that returns
> the Model Name as the sub-index for the arrays, hence allowing me to
> use Set::extract?
>
> 2- If 1 is not possible or even if it is, Do we hae a way to just get
> the elements containing data from the array. For instance, something
> like the following:
>
> $aDestSummary = Set::extract($aDestinationSummary, '{n}');
>
> I can always use regular php to iterate over the code and extract what
> I want; just wondering what the different approaches would be in this
> particular case, since I've come to really like Set::extract.
>
> Thanks in advance,
>
> 3- Bonus question while I am at it:
>
> Rails has a respond_to method that allows you to completely bypass the
> view and render from within the controller. This is quite helpful for
> instances where you are doing lots of ajax. Currently my application
> is 100 % ajax/javascript in the front end. I usually get the data that
> I want, set the variables for the views and render from there. It
> would be nice however to render right from my controller since I
> already have everything I want there and my view is nothing but an
> echo of json. Is there a respond_to equivalent or a similar approach?
>
> Thanks in advance,
>
> Alfredo
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to