Page 1 of 1

CakePHP call to a member function on a non object .

Posted: Thu Aug 26, 2010 5:35 pm
by lovelf
Does anyone determine what's wrong with this code?

Code: Select all

<?php
class PostsController extends AppController
{
var $name='Posts';

function index(){
$posts=$this->post->find('all',array('id','title','content','created','modified','published'), 'id DESC');
$this->set(compact('posts'));
}

}
?>
Call to a member function find() on a non-object in E:\xampp\htdocs\cake\app\controllers\posts_controller.php on line 7

Re: CakePHP call to a member function on a non object .

Posted: Thu Aug 26, 2010 6:56 pm
by Jonah Bron
If that's your entire class, then there is apparently no "post" variable. $this is a reference to an objects self, and it has no property "post".