Using Propel ORM in my own custom classes

Posted by Stick it to THE MAN on Stack Overflow See other posts from Stack Overflow or by Stick it to THE MAN
Published on 2010-03-19T15:53:46Z Indexed on 2010/03/19 18:01 UTC
Read the original article Hit count: 496

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about php

Related posts about propel