/** * @return string */ public function calculateSubQuery() { if (!$this->model) { $this->getModel(); //$this->model=$this->add($this->model_name); } /** @type SQL_Model $this->model */ if ($this->display_field) { $title = $this->model->dsql()->del('fields'); $this->model->getElement($this->display_field)->updateSelectQuery($title); } elseif ($this->model->hasMethod('titleQuery')) { $title = $this->model->titleQuery(); } else { // possibly references non-sql model, so just display field value return $this->owner->dsql()->bt($this->short_name); } $title->del('order')->where($this, $title->getField($this->model->id_field)); return $title; }