简体   繁体   中英

How it is possible to zend creating object of Zend framework model in controller or view?

My question is: If we create any object of one class, that class file should be included in our file .In zend frame work. How is this possible without including that file?

example: If I have indexcontrolle r in controller folder and Article model with name Article.php in model folder then how is articale.php available in index controller?

class IndexController extends Zend_Controller_Action {

  private $_model;

  public function indexAction() {

  $model=new Model_Article();/*how it is possible where and when this file include in index controller */

   }
}
?>

sorry for my poor English

assuming you are using zf1 version not zf2 , you can do it with,

 $model = new Application_Model_Article(); 

where article.php is under model folder.

you can call this in any of the controller and any of the action. then you can use for example $model->fetchAll(); to Invoke any function of your model..

Zend Autoloader is responsible for automatic class loading. It uses __autoload . You can read more about it here and here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM