I upgraded to a newer version of Symfony today (v1.0.6) and had a hell of time getting the trivial task of connecting to the database working.
I was able to obtain a connection, by doing
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$con = $databaseManager->getDatabase('propel');
but that’s not the ideal way, and not the way symfony gets the database handle.
$con = Propel::getConnection('propel');
on the otherhand throws an excpetion.
Fatal error: Uncaught exception ‘PropelException’ with message ‘No connection params set for propel’
First, it was important to check that config/schema.xml is correct
<database name=”propel” defaultIdMethod=”native”>
And that
config/databases.yml has a connection profile for
propel
All that was good. But for some reason sfPropelAutoload was not geting loaded.
If I manually included it
include './lib/symfony-1.0.7/lib/addon/propel/sfPropelAutoload.php'It was clearly listed in the autoloader.yml
it would work, but still not desirable.
The following was in my autoloader config,
propel_addon:
name: propel addon
files:
Propel: %SF_SYMFONY_LIB_DIR%/addon/propel/sfPropelAutoload.php
but it still wouldn’t load my sfPropelAutoload class. Adding the following made it start working…
symfony_orm:
name: symfony orm classes
files:
Propel: %SF_SYMFONY_LIB_DIR%/addon/propel/sfPropelAutoload.php
Criteria: %SF_SYMFONY_LIB_DIR%/vendor/propel/util/Criteria.php
SQLException: %SF_SYMFONY_LIB_DIR%/vendor/creole/SQLException.php
DatabaseMap: %SF_SYMFONY_LIB_DIR%/vendor/propel/map/DatabaseMap.php