对不起我的英文,但请帮助我。我怎样才能在模块中找到模型。我使用Zend Framework 1.12,我在命令行中运行php文件。示例代码:
//file located in project/scripts/test.php
<?php
//ini_set("display_errors","1"); ini_set("error_reporting", E_ALL);
// Initialize the application path and autoloading
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', $argv[1]);
set_include_path(implode(PATH_SEPARATOR, array(
APPLICATION_PATH . '/../library',
get_include_path(),
)));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
// Initialize Zend_Application
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
//this model i can find
$sendQueueModel = new Application_Model_DbTable_SendQueue();
//but this i can't. Managers - this is module in project
$managersMOdel = new Managers_Model_Company();
答案 0 :(得分:0)
该模块未加载这就是您无法访问模型的原因。我们通常会在Bootstap.php
中添加自动加载器,在这里您应该尝试相同的代码来加载它。 (初始化Zend_Application
后)
$autoLoader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Managers',
'basePath' => APPLICATION_PATH . '/modules/managers'
));