我使用Pomm包为我的symfony项目和我有一个问题 我创建了一个复杂的查询和我的结果实例相同的对象具有不同的属性。 这只是例如,但这个请求有关系 - >很多Pomm Bundle相同spl_object_hash但对象不同
我知道这个请求(1 - >很多)从关系的角度来看是不正确的,但我想了解pomm如何生成两次相同的对象引用
public function getSousFamilleParametreListing(Where $condition = null,$locale='fr')
{
$sql ="
select
{projection}
from
{sousfamilleparametre} sfp
inner join {parametre} par ON sfp.\"Parametre\" = par.\"ID\"
inner join {parametre_valeur} pav ON pav.\"Parametre\" = sfp.\"Parametre\"
inner join {valeur} val ON pav.\"Valeur\" = val.\"ID\"
where {condition}
order by sfp.\"Niveau\", sfp.\"Pos\", pav.\"Pos\""
;
$projection = $this->createProjection()
->setField('nom_param','par."Nom"','text')
->setField('type_param','par."Type"','text')
->setField('pos_valeur', 'pav."Pos"','text')
->setField('Valeur', 'val."ID"','text')
->setField('nom_valeur','val."Nom"','text')
->setField('couleur_valeur','val."ValCouleur"','text')
->setField('sur_mesure','val."SurMesure"','boolean');
$parametre = $this->getSession()
->getModel(ParametreModel::class);
$valeur = $this->getSession()
->getModel(ValeurModel::class);
$parametre_valeur = $this->getSession()
->getModel(ParametrevaleurModel::class);
$condition = (new Where)->andWhere($condition);
$sql = strtr(
$sql,
[
'{projection}' => $projection->formatFieldsWithFieldAlias('sfp'),
'{sousfamilleparametre}'=> $this->structure->getRelation(),
'{parametre}' => $parametre->getStructure()->getRelation(),
'{valeur}' => $valeur->getStructure()->getRelation(),
'{parametre_valeur}' => $parametre_valeur->getStructure()->getRelation(),
'{locale}' => $locale,
'{condition}' => $condition,
]
);
return $this->query($sql,$condition->getValues(),$projection);
}
而且的var_dump结果:
object(AppBundle\Entity\Model\MyDb1\PublicSchema\Sousfamilleparametre)#574 (2) {
["container":protected]=>
array(11) {
["SousFamille"]=>
int(8)
["Parametre"]=>
int(375)
["Pos"]=>
int(0)
["Niveau"]=>
int(1)
["nom_param"]=>
string(6) "TAILLE"
["type_param"]=>
string(1) "6"
["pos_valeur"]=>
string(1) "0"
["Valeur"]=>
string(1) "7"
["nom_valeur"]=>
string(2) "T1"
["couleur_valeur"]=>
string(7) "#4F4FFF"
["sur_mesure"]=>
bool(false)
}
["status":"PommProject\ModelManager\Model\FlexibleEntity\FlexibleContainer":private]=>
int(1)
}
string(32) "0000000067acae310000000004f8d20f"
object(AppBundle\Entity\Model\MyDb1\PublicSchema\Sousfamilleparametre)#574 (2) {
["container":protected]=>
array(11) {
["SousFamille"]=>
int(8)
["Parametre"]=>
int(375)
["Pos"]=>
int(0)
["Niveau"]=>
int(1)
["nom_param"]=>
string(6) "TAILLE"
["type_param"]=>
string(1) "6"
["pos_valeur"]=>
string(1) "1"
["Valeur"]=>
string(1) "8"
["nom_valeur"]=>
string(2) "T2"
["couleur_valeur"]=>
string(7) "#2424FF"
["sur_mesure"]=>
bool(false)
}
["status":"PommProject\ModelManager\Model\FlexibleEntity\FlexibleContainer":private]=>
int(1)
}
string(32) "0000000067acae310000000004f8d20f"