Don't you kind of hate cake's ability to do the same thing a bunch of
different ways?

2009/6/23 mehodgson <mehodg...@gmail.com>

>
> Have you tried using $this->loadModel('ModelName'); in your controller
> instead of App::import?  Not sure if it will work for what you are
> doing, but I have done similar things using it without issue.
>
>
> On Jun 15, 2:28 am, VVilku <wil...@interia.pl> wrote:
> > Hello (and sorry for my english) :)
> >
> > I have a small problem with the import model, and the condition in the
> > method of using 'find'. Terms of use related model. The condition has
> > a reference to a related model (belongsTo).
> >
> > A simple example:
> >
> > I have 2 models:
> > 1) User
> > class User extends AppModel {
> >         var $name = 'User';
> >         var $hasMany = array(
> >                         'Memoir' => array('className' => 'Memoir',
> >
> 'foreignKey' => 'user_id',
> >
> 'dependent' => false,
> >                         ),
> >         );
> > 2) Memoir
> > class Memoir extends AppModel {
> >         var $name = 'Memoir';
> >         var $belongsTo = array(
> >                         'User' => array('className' => 'User',
> >
> 'foreignKey' => 'user_id',
> >                         )
> >         );
> >
> > I have this condition for paginate options::
> > $this->paginate = array(
> >             'conditions'=>array('Memoir.status' => 1, 'User.status' =>
> > 1),
> >             'order'=>array('Memoir.updated'=>'desc'),
> >             );"
> >
> > When I use it in the controller, everything is ok.
> >
> > But when I try to use it after the import model in to another
> > controller, I receives an error.
> >
> > I tried App::import and ClassRegistry::init().
> >
> >                 //App::import('Model', $section['model']);
> >                 //$model = new $section['model']();
> >                 $model =& ClassRegistry::init($section['model']);
> >
> >                 $results = $model->find('all', array
> > ( 'conditions'=>array('Memoir.status' => 1, 'User.status' => 1)));
> >
> > SQL Error: 1054: Unknown column 'User.status' in 'where clause'
> >
> > I understand that the imported model is not somehow related to the
> > model of 'User'.
> > What can I do? Please :)
> >
> > I'm stuck.
> >
>

--~--~---------~--~----~------------~-------~--~----~
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