Retrieving data in Symfony using a model class

Say I have a model Ecosystemautomatically created using symfony from mine schema.yml. At some point in the code, I would like to get the records from the table.

I know there are several ways to do this with the Doctrine / Propel classes, but is there a way to do this directly using the model? I thought something like this:

$ecosystem = new Ecosystem();
$records = $ecosystem->find(...);

By the way, what is the preferred method for this kind of thing?

I am developing using CakePHP, and requests directly from Doctrine seem unnatural to me. What if I decide to switch to Propel tomorrow?

Thank!

+3
source share
2 answers

, Ecosystem. Doctrine :

  • Ecosystem ( Ecosystem.class.php) - Ecosystem
  • EcoSystemTable ( EcosystemTable.class.php) - singleton class Ecosystem

*Table. ?

Doctrine::getTable('Ecosystem')

Doctrine_Core::getTable('Ecosystem')

EcosystemTable::getInstance()

$obj->getTable(); // where $obj is instance of Doctrine_Record

:

+7

- , * , : $ record = Doctrine:: getTable ('Ecosystem') → find (1) id = 1. : http://www.doctrine-project.org/documentation/manual/1_0/en/dql-doctrine-query-language:magic-finders , DQL-, .

+1

Source: https://habr.com/ru/post/1792225/


All Articles