public function getQueryString(QueryContext $context) { if (!$this->subQuery) { if ($this->subQueryLimit) { throw new QueryException("Must be sub-query in [" . ConditionQueryBuilder::toString($context, $this->conditions) . "]"); } return ConditionQueryBuilder::toString($context, $this->conditions); } else { $context->schema($this->subQueryTableSchema); if (!$this->softDeleteLess && $this->subQueryTableSchema->getSoftDelete()) { $this->addCondition(ConditionInfo::make(ConditionInfo::CONDITION_AND, WhereConditionBuilder::makeNormal($this->subQueryTableSchema->getFieldSymbol(TableSchema::SOFT_DELETE_FIELD, false), '=', 0))); } $statements = array(); $statements[] = SelectionQueryBuilder::toString($context, $this->selectFields); $statements[] = 'FROM ' . $this->subQueryTableSchema->getSymbol(); $condition = ConditionQueryBuilder::toString($context, $this->conditions); if (isset($condition)) { $statements[] = "WHERE " . $condition; } return implode(' ', $statements); } }
private function parseField(TableSchema $schema, $field) { if (false === array_search($field, $schema->columns())) { return false; } return $schema->getFieldSymbol($field); }