Propel ORM을 사용하여 Symfony 프로젝트에서 Criteria를 사용하여 복잡한 쿼리를 수행하려고합니다.Symfony Criteria 예기치 않은 동작에 참여하십시오.
내가 만들고 싶어 쿼리는 인간 즉,이다 :
Select from the 'interface' table the registers that:
- 1 are associated with a process (with a link table)
- 2 have a name similat to $name
- 3 its destiny application's name is $apd (application accecible by foreign key)
- 4 its originapplication's name is $apo (application accecible by foreign key)
여기
내가 만든 코드 및 작동하지 : 내가 SQL을 볼 수있는 $c->toString()
을 행한 후
$c = new Criteria();
$c->addJoin($linkPeer::CODIGO_INTERFASE,$intPeer::CODIGO_INTERFASE); //1
$c->add($linkPeer::CODIGO_PROCESONEGOCIO,$this->getCodigoProcesonegocio());//1
if($name){
$name = '%'.$name.'%'; //2
$c->add($intPeer::NOMBRE_INTERFASE,$name,Criteria::LIKE); //2
}
if($apd){
$apd = '%'.$apd.'%'; //3
$c->addJoin($appPeer::CODIGO_APLICACION,$intPeer::CODIGO_APLICACION_DESTINO);//3
$c->add($appPeer::NOMBRE_APLICACION,$apd,Criteria::LIKE); //3
}
if($apo){
$apo = '%'.$apo.'%';//4
$c->addJoin($appPeer::CODIGO_APLICACION,$intPeer::CODIGO_APLICACION_ORIGEN);//4
$c->add($appPeer::NOMBRE_APLICACION,$apo,Criteria::LIKE);//4
}
생성 및 나는 단지 $ apd 값을 보낼 때 SQL, 올바른, 또한 내가 $ apo 값을 보낼 때 보았다. 하지만 둘 다 보낼 때 $ apo AND
만 SQL에 표시됩니다.
$ c-> add (...) 호출이 고유 한 매개 변수와 동일하기는하지만 확실하지는 않습니다. 이 오류가 있습니까? 내 쿼리를 올바르게 생성하는 가장 좋은 방법은 무엇입니까?
감사합니다. : D