douyangcheng4965 2010-04-13 09:27
浏览 27
已采纳

php zf project:models目录中的db类不会自动包含

I'm trying to create a Zend Framework project using PHP 5.3.2 and Zend Framework 1.10.3.

i created the source files of the project using the zend framework tool and the db related classes i created with zend-db-model-generator.

example:

in models directory i have the following:

FbUser.php - class Default_Model_FbUser
FbUserMapper.php - class Default_Model_FbUserMapper
DbTable/FbUser.php - class Default_Model_DbTable_FbUser

The models in the models directory should be included automatically when I use them in one of the controllers, but it seems that it doesn't.

what should i configure in order for the db class models will be auto-included when used ?

update

I tried adding the following code to the bootstrap file:

$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Default_');

the autoloader still looks for Default/Model/FbUser.php in include path instead of Model/FbUser.php in the zf project.

  • 写回答

1条回答 默认 最新

  • douxingti9307 2010-04-13 10:57
    关注

    I did not need to use Zend_Loader_Autoloader at all, although it's a cool component to auto-load classes in your include path.

    i need to add to application.ini which is the main config of the application, the following line:

    appnamespace = "Default_"
    

    The program understands the application name space and then loads the db model classes properly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch