Using Propel ORM in my own custom classes
- by Stick it to THE MAN
I am refactoring a few classes I wrote a while ago, into my Symfony project (v1.3.2 with Propel ORM).
The classes originally used direct connections to the database, I want to refactor those classes (stored in $(SF_LIB_DIR)) so that I can call propel and also use the ORM objects.
To clarify, So for example, I want to be able to use code like this in my custom classes:
try {
$con = Propel::getConnection();
$c = new Criteria();
$foo = new PropelORMFooObject();
$foobar = PropelORMFooBarObjectPeer::fetch($c);
//set fields etc
$foo->setFooBar($foobar);
// now save using obtained connection ..
$foo->save($con)
}catch(SomeException $e)
{
//deal with it
}
I assume that I will need to add some require_once() statements to my custom libraries, but it is not clear which files to include. Does anyone know how to do this?