Why do you have the echo in test action of your controller ?

That's going to break things even if everything else was OK.

If you set debug to 2 or 3, you should get the SQL that was produced,
which will help diagnose your issue.

I don't think you should be calling the test method in the model, but
rather calling the find('all') for the model you need data from, so
for this scenario (assuming your relationships are correct), you'd
just do:

       function test() {
                $this->Blog->recursive = 2;
        }

And the data should be there for your test.ctp to display.

On Jan 9, 2:17 am, Miles J <mileswjohn...@gmail.com> wrote:
> This is still making no sense. Heres my controllers (hid $uses below)
> and models.
>
> <?php
> // controllers/blog_controller.php
> class BlogController extends AppController {
>         function test() {
>                 $this->EntriesTopic->test();
>                 exit();
>         }
>
> }
>
> // models/entries_topic.php
> class EntriesTopic extends AppModel {
>         var $belongsTo = array('Topic', 'Entry');
>
>         function test() {
>                 echo 'test';
>                 debug($this->find('all', array('recursive' => 2)));
>         }
>
> } ?>
>
> When I go to /blog/test/ I get the following errors. The damn model is
> not even being initialized, you can see it call AppModel instead of
> EntriesTopic, what am I missing here......
>
> Warning (512): SQL Error: 1064: You have an error in your SQL syntax;
> check the manual that corresponds to your MySQL server version for the
> right syntax to use near 'test' at line 1 [CORE\cake\libs\model
> \datasources\dbo_source.php, line 514]
>
> DboSource::showQuery() - CORE\cake\libs\model\datasources
> \dbo_source.php, line 514
> DboSource::execute() - CORE\cake\libs\model\datasources
> \dbo_source.php, line 201
> DboSource::fetchAll() - CORE\cake\libs\model\datasources
> \dbo_source.php, line 337
> DboSource::query() - CORE\cake\libs\model\datasources\dbo_source.php,
> line 298
> Model::call__() - CORE\cake\libs\model\model.php, line 436
> Overloadable::__call() - CORE\cake\libs\overloadable_php5.php, line 52
> AppModel::test() - [internal], line ??
> BlogController::test() - APP\controllers\blog_controller.php, line 52
> Object::dispatchMethod() - CORE\cake\libs\object.php, line 115
> Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 245
> Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 211
> [main] - APP\webroot\index.php, line 88
--~--~---------~--~----~------------~-------~--~----~
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