Using Doctrine with Module based Zend Framework layout

401 Views Asked by At

I have a not so standard layout for my zend framework application. I am implementing modules but in the mean time I only created the default module explicitly. Here is a link to a screenshot of the application layout [1]: http://img846.imageshack.us/f/projecttree.jpg/. I am also using Doctrine 1.2. When I do $ ./doctrine build-all-reload. I get the following error:

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

In the script folder I have two files doctrine with content:

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

and the other file doctrine.php contains:

<?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']);

How can I fix this.

The second problem is I have the following

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

Nothing gets saved. However when I do a var_dump($borrowerdetails->getValues()), I see all the values. However a var_dump($groupborrower) gives me null for all the properties. I have battled with this for a week now.

1

There are 1 best solutions below

0
On

This solution if for the second question in the post regarding the data not being saved. mridgway on the doctrine irc channel helped me with this. Basically when you get data from a subform, it still has the subform name as the root key hence I shd have used

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

That fixed my problem for me. Hope it helps.