2011-03-05 39 views
0

我有一個不那麼標準的佈局爲我的zend框架應用程序。我正在實現模塊,但同時我只明確創建了默認模塊。以下是應用程序佈局[1]截圖的鏈接:http://img846.imageshack.us/f/projecttree.jpg/。我也在使用Doctrine 1.2。當我做$ ./doctrine build-all-reload。我得到以下錯誤:基於模塊的Zend框架佈局使用Doctrine

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。現在我已經與這一週作鬥爭了。

回答

0

此解決方案如果針對第二個問題的帖子中的數據未保存。在教條irc頻道mridgway幫助我與此。基本上,當你從一個子窗體獲取數據,它仍然有表單名稱作爲根密鑰,因此我SHD已經使用

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

這固定我的問題對我來說。希望能幫助到你。