How about this:
$var = 'User';
$this->loadModel($var);
$user = $this->{$var}->read(null, 2);
$this->set(compact('user'));
On Nov 17, 4:50 pm, pharus <[email protected]> wrote:
> Yes ok, thanks for your answer. But for me it is important to get
> $this->loadModel('User', 2); working, because at coding time I do not
> know which model i will use.
>
> I am using it this way:
> $this->loadModel($var, 2);
>
> $var changes and it is possible to write is like above, but $id
> doesn't work.
>
> In my case $this->$var->read(null,2); does not work.
>
> On 17 Nov., 16:40, jburns <[email protected]> wrote:
>
>
>
> > I am using it this way:
>
> > $this->loadModel('User');
> > $user = $this->User->read(null, 2);
> > $this->set(compact('user'));
>
> > ...and it seems to work fine.
>
> > On Nov 17, 3:03 pm, pharus <[email protected]> wrote:
>
> > > I am usingloadModelas described
> > > here:http://book.cakephp.org/view/845/loadModel
>
> > > $this->loadModel('User', 2);
> > > $user = $this->User->read();
>
> > > But the id parameter doesn't work. The above code always returns the
> > > first user in the database and ignores my $id.
>
> > > Do I have to configure something special to getloadModelwith $id
> > > working?
>
> > > On Nov 14, 1:36 pm, "[email protected]"
>
> > > <[email protected]> wrote:
> > > > Try ClassRegistry::init('Post');
>
> > > > On Nov 14, 7:55 am, "Dr. Loboto" <[email protected]> wrote:
>
> > > > > Marcelo is wrong totally. App::import only include model file but not
> > > > > create and initialize model for you asloadModelwill do.
>
> > > > > On Nov 14, 6:10 am, Scott Dahl <[email protected]> wrote:
>
> > > > > > Marcelo,
>
> > > > > > Thanks for the update. I was unaware of that. I will stop using
> > > > > > that and
> > > > > > update my methods. Thanks again.
>
> > > > > > Scott
>
> > > > > > On Fri, Nov 13, 2009 at 12:11 PM, Marcelo Andrade
> > > > > > <[email protected]>wrote:
>
> > > > > > > On Fri, Nov 13, 2009 at 3:06 PM, Scott Dahl
> > > > > > > <[email protected]> wrote:
> > > > > > > > $this->loadModel('ModelName');
> > > > > > > > $results = $this->ModelName->find('list');
>
> > > > > > > "loadModel" is deprecated. Use
> > > > > > > App::import('model', 'ModelName');
> > > > > > > instead.
>
> > > > > > > Best regards.
>
> > > > > > > --
> > > > > > > MARCELO DE F. ANDRADE
> > > > > > > Belem, PA, Amazonia, Brazil
> > > > > > > Linux User #221105
>
> > > > > > > --
>
> > > > > > > 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]<cake-php%[email protected]
> > > > > > > om>
> > > > > > > .
> > > > > > > For more options, visit this group at
> > > > > > >http://groups.google.com/group/cake-php?hl=.-Zitierten Text
> > > > > > >ausblenden -
>
> > - Zitierten Text anzeigen -
--
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=.