You might want to consider using the Model's afterFind() method,
instead. But, if you'd rather do it in the controller, the best way to
figure out how to access your data is to toss a debug($mydata) in
there. (seems to be my standard response these days ;-) You're
probably getting hung up on the numerical indexes for a hasMany
relation or something.

On Fri, Mar 20, 2009 at 11:19 AM, ryanam1 <[email protected]> wrote:
>
> Hi,
>
> How can I access data within a controller?
>
> Lets say I have the following find() method in my controller
>
> $mydata=$this->User->find('all', array('conditions'=>'new;),
> 'fields'=>array('name'))
>
> Let's say I wanted to do some sort of proccessing to that data before
> outputting to a view.... How would I do that?
>
> I see examples of how to output that data in the view but I see none
> about accessing the data from within the controller.
>
> I figure I should do a loop but how should I write $mydata?
>
> Should it be like this:  $mydata['User']['name']  ?  That seems to
> work in the view but I get a "Undefined Index" error when I write it
> that  way from within the controller.
>
> I don't have the issue when a method returns one record such as field
> () because it is not returning an array....
>
> I hope I'm not confusing anyone :(
>
> >
>

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

Reply via email to