views:

22

answers:

1

I've run this code

Zend_Loader::loadClass("Admin_Models_DbTable_News");

and my application has this folder structure

alt text

Why do I get this:

An error occurred

Application error

+1  A: 

Zend Framework ships with a concrete implementation of Zend_Loader_Autoloader_Resource that contains resource type mappings that cover the default recommended directory structure for Zend Framework MVC applications.

This loader, Zend_Application_Module_Autoloader, comes with the following mappings:

  forms/       => Form
  models/      => Model
      DbTable/ => Model_DbTable
      mappers/ => Model_Mapper
  plugins/     => Plugin
  services/    => Service
  views/
      helpers  => View_Helper
      filters  => View_Filter

Given your example, your class should be called "Admin_Model_DbTable_News". Note that the "s" is left out. This class should be put in application/modules/admin/models/DbTable/News.php

Andries Seutens
Is this autoloader automatic or do I have to implement it in my application?
Rodrigo Alves
i'm still getting An error occurred - Application error
Rodrigo Alves
I've found out that it's happening because of my model. Check it out: [http://paste2.org/p/972127](http://paste2.org/p/972127). Is there something wrong?
Rodrigo Alves
Your class should be named Admin_Model_DbTable_News as it was before. The autoloader is not setup automatically, normally you would do this in your public/index.php file using: require_once 'Zend/Loader/Autoloader.php';Zend_Loader_Autoloader::getInstance();
Tim Fountain
At least, your model's name should be 'Admin_Model_DbTable_News' instead of 'Admin_Model_News'
Vika