1
votes

Propel 1.6 and Symfony 1.4

I'm looking for a way to programmatically set the default propel connection for the length of an entire php process. The issue is that I'm using an alternative db for testing purposes and I have a good deal of code that doesn't pass the PropelPDO object currently.

Can this be done? Any tips? Thanks.

2
Hi there. I've added your answer as community wiki, and reverted the update. If you self-answer (it is encouraged) then just add an answer yourself, and tick it to remove it from unanswered lists. Thanks! - halfer

2 Answers

1
votes

Why not use environments in your databases.yml?

dev:
  propel:
    class:        sfPropelDatabase
    param:
      classname:  DebugPDO
    etc, etc


stage:
  propel:
    class:        sfPropelDatabase
    param:
      classname:  PropelPDO
  etc, etc


prod:
  propel:
    class:        sfPropelDatabase
    param:
      classname:  PropelPDO
  etc, etc
1
votes

So, the solution to this was to use the following, pretty clean and sweet:

//override the "default" "propel" dsn and set it to our testing db!
\Propel::setConnection(
    "propel",
    Propel::getConnection(SqliteSetup::$databaseName)
);