Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 筛选联接数据_Sql_Symfony_Doctrine Orm - Fatal编程技术网

Sql 筛选联接数据

Sql 筛选联接数据,sql,symfony,doctrine-orm,Sql,Symfony,Doctrine Orm,我有一个有几个实体的模型。 最重要的是由关联Transportstatus连接的Transportevent和Transporteventtype。 因此,Transportstatus包含这两个表的外键 在我的查询中,我试图筛选Transportstatustype id值。我的查询位于Transportevent存储库中,$this->getAlias()返回“Transportevent” 公共函数findAllDispatchedEvents($limit) { $transportst

我有一个有几个实体的模型。 最重要的是由关联Transportstatus连接的Transportevent和Transporteventtype。 因此,Transportstatus包含这两个表的外键

在我的查询中,我试图筛选Transportstatustype id值。我的查询位于Transportevent存储库中,$this->getAlias()返回“Transportevent”

公共函数findAllDispatchedEvents($limit)
{
$transportstatusAlias=“ts”;
$transporteventtypeAlias=“tet”;
$transportstatustypeAlias=“tst”;
$crewAlias=“c”;
$qb=$this->createQueryBuilder($this->getAlias());
$qb->leftJoin($this->getAlias()..crew',$crewAlias)
->leftJoin($this->getAlias()。.transporteventtype',$transporteventtypeAlias)
->leftJoin($this->getAlias()。.transportstatuses',$transportstatusAlias)
->leftJoin($transportstatusAlias.'.transportstatustype',$transportstatustypeAlias)
->其中($this->getAlias().“.transporteventtype 3”)
->andWhere($crewAlias。“.crewid不为空”)
->andWhere($transportstatustypeAlias。“.tstypeid不在(10,15,17)”中)
->orderBy($this->getAlias().“.actualstart”、“DESC”)
->setMaxResults($limit);
返回$qb->getQuery()->getResult();
}
然而,我没有得到我需要的。似乎不可能在联接中的另一个表上执行where子句

还是我做错了什么

正如您所看到的,在某些条件下,我需要这些结果,其中tstypeid不在数组中(10、15、17)。但我也得到了这些值。 有什么建议吗?

public function findAllDispatchedEvents($limit)
    {

        $transportstatusAlias = "ts";
        $transporteventtypeAlias = "tet";
        $transportstatustypeAlias = "tst";
        $crewAlias = "c";

        $qb = $this->createQueryBuilder($this->getAlias());

        $qb->leftJoin($this->getAlias() . '.crew', $crewAlias)
            ->leftJoin($this->getAlias() . '.transporteventtype', $transporteventtypeAlias)
            ->leftJoin($this->getAlias() . '.transportstatuses', $transportstatusAlias)
            ->leftJoin($transportstatusAlias . '.transportstatustype', $transportstatustypeAlias)
            ->where($this->getAlias() . ".transporteventtype <> 3")
            ->andWhere($crewAlias . ".crewid IS NOT NULL")
            ->andWhere($transportstatustypeAlias . ".tstypeid NOT IN (10, 15, 17)")
            ->orderBy($this->getAlias() . ".actualstart", "DESC")
            ->setMaxResults($limit);

        return $qb->getQuery()->getResult();
    }