【发布时间】:2011-03-23 05:52:50
【问题描述】:
我正在尝试让 Propel 在我的 Zend 应用程序中工作,似乎我可以加载 Propel 库(从库/propel),但是当调用时我得到异常:'运行时配置文件中没有连接信息for datasource [default]'(当我尝试建立连接时:'Propel::getConnection')。我的数据库甚至没有被命名为“默认”。我的 bootstrap.php 中有这个来自另一个 SO 问题/答案:
require_once 'propel/Propel.php';
Propel::setConfiguration($this->getOptions('propel/MyPropel-conf.php'));
Propel::initialize();
// so we can get the connection from the registry easily
return Propel::getConnection();
我希望 Propel 配置(以及 classmap conf)位于“/application/configs”中(现在也有副本),但我想如果我可以让 Propel 从 library/propel 加载,那么也许将我的“conf”文件移到那里,我也可以让它们加载。似乎如果我通过手动加载参数来“强制”配置,或者如果我似乎将它放在临时的“正确”位置(或使用绝对路径),那么我得到的异常是: '无法打开 PDO 连接 [wrapped: SQLSTATE [28000] [1045] 用户 'www-data'@'localhost' 的访问被拒绝 好像 Propel 没有注意我的配置。 我的配置看起来像这样;从xml转换:
$conf = array (
'datasources' =>
array (
'unmActTestDB' =>
array (
'adapter' => 'mysql',
'connection' =>
array (
'dsn' => 'mysql://root:PASSWORD@localhost/unmActTestDB',
),
),
'default' => 'unmActTestDB',
),
'log' =>
array (
'ident' => 'propel-act',
'level' => '7',
),
'generator_version' => '1.5.6',
);
$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-unmActTestDB-conf.php');
return $conf;
如果有帮助,我仍然在 application.ini 文件中加载 Zend PDO DB 适配器,这会导致冲突吗?有没有让 Propel 与 Zend 一起工作的标准方法?或者任何人都可以看到我做错了什么?
我在 SO 上看过几个帖子,还有几个受欢迎的帖子,比如这个 The Adventures Of Merging Propel With Zend Framework 和 Zend 开发区 Integrating Propel with the Zend Framework 的这个帖子,其中包括 Propel Docs。他们一直很有帮助,但我真的很挣扎。提前致谢!我当前的 Zend 目录结构如下所示(在 library/propel 文件夹中还有两个 propel conf:
【问题讨论】:
-
我已经解决了路径问题,连接问题是由于我在运行时 conf xml 文件中忽略了
和 造成的。 -
您应该将其发布为答案。回答自己的问题没有错
-
@PHil Brown 你说得对,对不起......我会马上解决的! :)
标签: database zend-framework orm pdo propel