I'd like some help from the community, if possible.
We have a project at work, and time has come for refactoring. We are using PHP 5 and Propel 1.6 as ORM layer. The idea, actually, is pretty simple: we are trying to obtain all relevant information at the same time.
However, this information is not always directly related to the main class (or, in other words, to the main table). For example:
return (
$this->leftJoin( "IES.Pessoa mant" )
->leftJoin( "mant.Papel subpapel" )
->where( "subpapel.tipo = ?", Tipo_papel::IES )
->leftJoin( "subpapel.RelacionamentoRelatedByIdSubPapel relm" )
->where( "relm.tipo = ?", Tipo_relacionamento::MANTENEDORA_IES )
->leftJoin( "relm.PapelRelatedByIdSuperPapel superpapel" )
->leftJoinWith( "superpapel.Pessoa iesm" )
->where( 'superpapel.tipo = ?', Tipo_papel::MANTENEDORA_IES )
);
This is the code of a function in a ModelCriteria from our model layer. The idea is to obtain 'iesm' related to one 'IES'.
But, here we have a problem. It happens that 'IES' is already related to one entity 'Pessoa'. So, when this code is applied, this object will be lost, giving space to the entity 'Pessoa' related to 'iesm'.
So the basic question is: I would like to set the property 'iesm' inside 'IES' object, and not Pessoa, which is set because of Propel mapping. That being said, how can I do that? Is it even possible? I'd like to set 'iesm' based on the alias created on leftJoinWith.
And another question, that showed immediately after this: if there is no direct relation in the database, how can I set this object, using the same idea? Trying to explain better: this 'iesm' is actually an object of type 'Pessoa_juridica'. And 'Pessoa_juridica' is not directly related to 'IES'. How could this 'Pessoa_juridica' be set inside 'IES' object?
I don't even know if this is the best way of using it, so any other ideas are welcome. If you want further explanation, just let me know.