Rodrigo Souza
Rodrigo Souza

Reputation: 7332

Why am I getting Application error while trying to load a model?

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

Upvotes: 0

Views: 296

Answers (1)

Andries
Andries

Reputation: 81

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

Upvotes: 1

Related Questions