Symfony1 如何定义已左键联接的表

Symfony1 如何定义已左键联接的表,symfony1,doctrine,Symfony1,Doctrine,我需要为左联接表的字段设置条件 所以我需要知道: 这张桌子是左联的吗? 如果是,则使用leftjoined表的哪个别名来添加新条件 下面是当前代码示例: class PStudentFormFilter extends BasePStudentFormFilter { public function configure() { $this->setWidget('name', new sfWidgetFormInput()); $this->setWidge

我需要为左联接表的字段设置条件

所以我需要知道: 这张桌子是左联的吗? 如果是,则使用leftjoined表的哪个别名来添加新条件

下面是当前代码示例:

class PStudentFormFilter extends BasePStudentFormFilter
{
  public function configure()
  {

    $this->setWidget('name', new sfWidgetFormInput());
    $this->setWidget('phone', new sfWidgetFormInput());

    $this->setValidator('name', new sfValidatorPass(array('required' => false)));
    $this->setValidator('phone', new sfValidatorPass(array('required' => false)));
  }


  private function leftJoinPersonalInfoQuery(Doctrine_Query $query)
  {
    if (isset($this->__leftJoinPersonalInfoQuery)) return;

    $this->__leftJoinPersonalInfoQuery = true;
    $query->leftJoin($query->getRootAlias().'.PersonalInfo pi');
  }

  public function addNameColumnQuery(Doctrine_Query $query, $field, $value)
  {
    $value = trim($value['text']);
    if (!$value)
    {
      return;
    }

    $value = str_replace(' ', '%', $value);

    $this->leftJoinPersonalInfoQuery($query);

    $query->andWhere("CONCAT(pi.surname, ' ', pi.first_name, ' ', pi.patronymic) LIKE ?", "%$value%");
  }

  public function addPhoneColumnQuery(Doctrine_Query $query, $field, $value)
  {

    $value = trim($value['text']);
    if (!$value)
    {
      return;
    }

    $value = str_replace(' ', '%', $value);

    $this->leftJoinPersonalInfoQuery($query);

    $query->andWhere("pi.mobile_phone LIKE ?", "%$value%");
  }

}

您可以尝试分析
$query->getDqlPart('from')
的返回值以使其正常工作