There is a getModel function from Felix here
http://www.thinkingphp.org/2007/01/22/how-to-properly-create-a-model-instance-manually/

Put that in a component called common and then at the top of the
component you want to use set $components = array('common') to make
the function available.

Then simply do $Mytable = $this->common->getModel('MyTable');

Thereafter you can do whatever you need, e.g. $results = $MyTable-
>findall();

ianh

On 20 Mar, 13:35, "Aldo" <[EMAIL PROTECTED]> wrote:
> Hello
>
> I'm trying to make a database call from a component, but independent
> from controller.
> Is there a way to set the table to use from the component?
>
> class CommonComponent extends Object
> {
>         var $controller = true;
>
>         function startup(&$controller)
>         {
>                 // This method takes a reference to the controller which is 
> loading
> it.
>                 // Perform controller initialization here.
>                 $this->controller = &$controller;
>         }
>
>         function doFoo()
>         {
>                 // Here i would like to set a table where to look
>                 $controllerName = $this->controller->name;
>                 $output = $this->controller->$controllerName->findAll('id=2');
>                 return $output;
>         }
>
> }
>
> Thanks for any help!
> Aldo


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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