0

对不起我的英语,但请帮助我。如何在模块中找到模型。我使用 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();
4

1 回答 1

0

该模块未加载,这就是您无法访问模型的原因。通常我们在中添加自动加载器Bootstap.php,在这里你应该尝试相同的代码来加载它。(初始化后Zend_Application

  $autoLoader = new Zend_Application_Module_Autoloader(array(
                'namespace' => 'Managers',
                'basePath' => APPLICATION_PATH . '/modules/managers'
            ));
于 2013-10-30T09:35:42.110 回答