0

我的 zend 框架应用程序的布局不太标准。我正在实现模块,但同时我只明确创建了默认模块。这是应用程序布局 [1] 的屏幕截图的链接:http: //img846.imageshack.us/f/projecttree.jpg/。我也在使用 Doctrine 1.2。当我这样做的时候$ ./doctrine build-all-reload。我收到以下错误:

PHP Fatal error:  Cannot redeclare class Gepm_Model_Base_Account in      /shared/www/gepm2/library/Gepm/Model/Base/Account.php on line 73
PHP Stack trace:
PHP   1. {main}() /shared/www/gepm2/application/scripts/doctrine:0
PHP   2. include() /shared/www/gepm2/application/scripts/doctrine:4
PHP   3. Doctrine_Cli->run() /shared/www/gepm2/application/scripts/doctrine.php:30
PHP   4. Doctrine_Cli->_run() /shared/www/gepm2/library/Doctrine/Cli.php:452
PHP   5. Doctrine_Cli->executeTask() /shared/www/gepm2/library/Doctrine/Cli.php:498
PHP   6. Doctrine_Task_BuildAllReload->execute() /shared/www/gepm2/library/Doctrine/Cli.php:516
PHP   7. Doctrine_Task_LoadData->execute() /shared/www/gepm2/library/Doctrine/Task/BuildAllReload.php:56
PHP   8. Doctrine_Core::loadData() /shared/www/gepm2/library/Doctrine/Task/LoadData.php:43
PHP   9. Doctrine_Data->importData() /shared/www/gepm2/library/Doctrine/Core.php:1001
PHP  10. Doctrine_Data_Import->doImport() /shared/www/gepm2/library/Doctrine/Data.php:222
PHP  11. Doctrine_Data->purge() /shared/www/gepm2/library/Doctrine/Data/Import.php:115
PHP  12. Doctrine_Core::getLoadedModels() /shared/www/gepm2/library/Doctrine/Data.php:263
PHP  13. Doctrine_Core::filterInvalidModels() /shared/www/gepm2/library/Doctrine/Core.php:720
PHP  14. Doctrine_Core::isValidModelClass() /shared/www/gepm2/library/Doctrine/Core.php:767
PHP  15. class_exists() /shared/www/gepm2/library/Doctrine/Core.php:788
PHP  16. Doctrine_Core::modelsAutoload() /shared/www/gepm2/library/Doctrine/Core.php:0

在脚本文件夹中,我有两个包含内容的文件学说:

#!/usr/bin/env php
<?php
chdir(dirname(__FILE__));
include('doctrine.php');

另一个文件doctrine.php包含:

<?php

// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/..'));

// Define application environment
 defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);

$application->getBootstrap()->bootstrap('doctrine');
$config = $application->getOption('doctrine');

$cli = new Doctrine_Cli($config);
$cli->run($_SERVER['argv']);

我怎样才能解决这个问题。

第二个问题是我有以下

            $borrowerdetails = $form->getSubForm('borrowerdetails');
            $groupborrower = new Gepm_Model_Borrower();
            $groupborrower->fromArray($borrowerdetails->getValues());
            $groupborrower->save();

什么都没有得救。但是,当我执行 var_dump($borrowerdetails->getValues()) 时,我看到了所有值。但是 var_dump($groupborrower) 给我所有属性的 null 。我已经为此奋斗了一个星期。

4

1 回答 1

0

此解决方案适用于帖子中关于未保存数据的第二个问题。教义 IRC 频道上的 mridgway 帮助我解决了这个问题。基本上,当您从子表单获取数据时,它仍然将子表单名称作为根键,因此我使用过

$values=$borrowerdetails->getValues();
$groupborrower->fromArray($values[borrowerdetails]);
$groupborrower->save();

这解决了我的问题。希望能帮助到你。

于 2011-03-07T17:23:09.417 回答