Hmmm....okay, so the default pages controller does: var $uses = null;

Which makes me think that setting your demo app's controller to
$uses=null causes no models to load in, which then means that when it
tries to query the DB, it doesn't have any models instantiated that it
can use to do so.

So....I arrived at the right conclusion for the wrong reasons on my
last reply. Still, you should try my suggestion of just
$useTable=false in your model rather than $uses=null in your
controller.

On Mar 18, 4:52 pm, "Walker Hamilton" <[EMAIL PROTECTED]> wrote:
> Okay! Now we're getting somewhere! What you want to do is always have
> a model for your controllers. The trick is to not have a db table for
> a model.
>
> ....So, instead of cutting the DB->Model->Controller->View chain at
> Controller, we're going to cut it at DB.
>
> create your model, and then put this in the class of the new model you
> created:
>
> $useTable = false;
>
> On Mar 18, 3:21 pm, "LSL" <[EMAIL PROTECTED]> wrote:
>
> > I'm really sorry that it seems I think CakePHP is wrong. I know that
> > it is probably my fault that I can't use it the right way. As I have
> > written in my first post - It's a great piece of SW.
>
> > Now I'm a bit closer to the problem. It seems that the error is
> > present only when I use controller without model ($uses=array() or
> > $uses=null). Other controllers seems OK and rendering my menus the
> > right way.
>
> > I have written miniapp to demonstrate that:
> > config/routes.php:
> > ...
> >         $Route->connect('/', array('controller' => 'index', 'action'
> > => 'index'));
> > ...
>
> > controllers/index_controller.php
> >   class IndexController extends AppController {
> >     var $name='Index';
> >     var $uses=null;
>
> >     function index() {
> >     }
> >   }
>
> > controllers/menu_items_controller.php:
> >   class MenuItemsController extends AppController {
> > var $scaffold;
> >   }
>
> > models/menu_item.php:
> >   class MenuItem extends AppModel {
> >     var $name='MenuItem';
> >   }
>
> > views/elements/menu.thtml:
> > <pre>Menu element: <?php print_r($menuElement);?></pre>
>
> > views/layouts/default.thtml:
> > <html>
> >   <body>
> >     <p><?=$this->renderElement('menu')?></p>
> >     <?=$content_for_layout?>
> >   </body>
> > </html>
>
> > app_controller.php:
> > class AppController extends Controller {
> >         var $uses=array('MenuItem');
>
> >         function beforeFilter() {
> >                 parent::beforeFilter();
> >                 $this->set('menuElement', $this->MenuItem->findAll());
> >         }
>
> > }
>
> > I don't know how to deal with this. Is CakPHP misused or is it some
> > error?
>
> > Thanks (and once again sorry).
>
> > Lukas
>
> > Walker Hamilton wrote:
> > > Do not start blaming the tool, until you have no proof it's not
> > > yourself to blame.....you were complimenting cakePHP in your first
> > > post, don't turn back on that compliment just because you are
> > > frustrated.


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