2009年8月3日星期一

Re: [fw-db] Creating an instance of database table

The problem here is that you are attempting to load the Category Model,
but its not loadable by the default autoloader.

Autoloading is where php files containing classes can be found on first
use without the use of require_once statements.

If you are using Zend_Application, you would need to call Category
'Default_Model_Category' for it to be autoloaded.

I suggest you have a look at the ZF quickstart application located here:

http://framework.zend.com/docs/quickstart

specifically take note to the class names, and their location in the
filesystem. There are also plenty of comments in there to help you
understand the anatomy of an application with Zend Framework.

Hope this helps,
Ralph Schindler


ashoms0a wrote:
> Hi there,
> I am a new zend framework user and I am having a problem in instantiating an
> instance of one of my model inside an action controller.
>
> I have one model as shown below
>
> require_once 'Zend/Db/Table/Abstract.php';
>
> class Category extends Zend_Db_Table_Abstract{
>
> protected $_name = 'category';
> }
>
> The controller is as shown below:
> require_once 'Zend/Controller/Action.php';
>
> class CatController extends Zend_Controller_Action {
>
> public $cat;
>
> public function init() {
>
> $this->cat = new Category();
> }
>
> public function indexAction() {
> }
>
> }
>
> But I am getting the below message and i don't know why:
>
> Fatal error: Class 'Category' not found in
> C:\wamp\www\eGal\application\controllers\CatController.php on line 21
>
> any help is highly appreciated
>

没有评论: