Let's say I have a model Ecosystem automatically generated with symfony from my schema.yml. At some point in the code, I would like to retrieve records from the table.
I know there are some ways to do this with Doctrine/Propel classes, but, is there a way of doing it with directly the model? I've been thinking in something like this:
$ecosystem = new Ecosystem();
$records = $ecosystem->find(...);
By the way, which is the preferred method to do this kind of things?
I've been developing with CakePHP and making queries directly with Doctrine doesn't seem natural to me. What if I decide to change to Propel tomorrow?
Thanks!
Suppose your model is Ecosystem.
Doctrine autogenerates two model classes for you:
Ecosystem (defined in Ecosystem.class.php) — objects of this class are actual ecosystem entitiesEcoSystemTable (defined in EcosystemTable.class.php) — singleton class to provide management over Ecosystem entitiesThis why all the entity management functionality is done with *Table classes. How to get them?
Doctrine::getTable('Ecosystem')
or
Doctrine_Core::getTable('Ecosystem')
or
EcosystemTable::getInstance()
or
$obj->getTable(); // where $obj is instance of Doctrine_Record
Further reading:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With