Transform the row's identity to where criteria
@return array
182722
protected function criteria() {
		$where = array();
		foreach ($this->getIdentity() as $col => $val) {
			if (isset($val)) {
				$where["$col="] = $val;
			} else {
				$where["$col IS"] = new QueryExpr("NULL");
			}
		}
		return $where;
	}
556987
public function getSchemaDataDefaults()
    {
        $data = parent::getSchemaDataDefaults();
        $data['data']['rows'] = $this->getRows();
        $data['data']['columns'] = $this->getColumns();
        $data['data']['maxlength'] =  $this->getMaxLength();
        return $data;
    }
704974
private function addConditionsToSqlWhithWhereIn(): string
    {
        if (count($this->wheresIn) === 0) {
            throw new OrmException('Argument 2 passed to "whereIn()" can not be an empty array.');
        }
        
        $paramsWhereIn = " ( ";

        foreach ($this->wheresIn as $value) {                
            $paramsWhereIn .= " ?, ";

            $this->wheresBindValue[] = $value;
        }

        $this->wheresIn = [];

        return rtrim($paramsWhereIn, ', ')." ) ";
    }
597619
public function toArray()
    {
        $query = [
            'numericFilters' => '',
            'facetFilters'   => '',
        ];

        if ($this->query != '') {
            $query['query'] = $this->query;
        }

        if ($this->useLocationAwareSearch) {
            $query['aroundLatLng'] = $this->lat.','.$this->lng;
            $query['aroundRadius'] = $this->aroundRadius;
        }

        foreach ($this->dateRestrictions as $dateRestriction) {
            $query['numericFilters'] .= ','.
                $dateRestriction['dateFieldName'].
                $dateRestriction['operation'].
                $dateRestriction['date']->getTimeStamp();
        }

        foreach ($this->numericFilters as $filter) {
            $query['numericFilters'] .= ','.$filter;
        }

        foreach ($this->facets as $facet) {
            $query['facetFilters'] .= ','.$facet;
        }

        $query['page'] = $this->page;
        $query['hitsPerPage'] = $this->hitsPerPage;

        return $query;
    }
868658
protected function buildWheres()
    {
        if (count($this->where) === 0) {
            return '';
        }

        // Use a ConditionSet to build the wheres
        $conditionSet = new Query\Condition\AndSet($this, $this->where);
        return "WHERE {$conditionSet->buildWithoutParentheses()}";
    }
251114
public function getRow()
	{
		$alias = $this->getAlias();
		$rows = static::findById( $this->id )->loadArray();
		$row = array_shift( $rows );
		$ret = $this->fromArray( $row[ $alias ], true );
		return $ret;
	}
262595
protected function whereStatement(): array
    {
        $where = parent::whereStatement();

        if (!empty($morphKey = $this->key(Record::MORPH_KEY))) {
            //HasOne relation support additional morph key
            $where['{@}.' . $this->key(Record::MORPH_KEY)] = $this->orm->define(
                get_class($this->parent),
                ORMInterface::R_ROLE_NAME
            );
        }

        return $where;
    }
1214363
private function getQueryFields() : array
    {
        $result = [];
        foreach ($this->criteria as $criteria) {
            $field = $this->table->aliasField($criteria->getField());
            if (! in_array($field, $result)) {
                $result[] = $field;
            }
        }

        foreach ($this->query->clause('select') as $field) {
            if (is_string($field) && ! in_array($field, $result)) {
                $result[] = $field;
            }
        }

        return $result;
    }
351078
protected function prepare($where)
    {
        if (is_string($where)) {
            return str_replace('{@}', $this->alias, $where);
        }

        if (!is_array($where)) {
            return $where;
        }

        $result = [];
        foreach ($where as $column => $value) {
            if (is_string($column) && !is_int($column)) {
                $column = str_replace('{@}', $this->alias, $column);
            }

            $result[$column] = !is_array($value) ? $value : $this->prepare($value);
        }

        return $result;
    }
776462
public function indexIdentities(): array
    {
        $pkName  = $this->getModelSchemas()->getPrimaryKey($this->getModelClass());
        $builder = $this->createIndexModelBuilder([$pkName]);
        /** @var Generator $data */
        $data   = $this->fetchColumn($builder, $builder->getModelClass(), $pkName);
        $result = iterator_to_array($data);

        return $result;
    }
125295
private function getUpdateQuery()
    {
        if (isset($this->parts['from'][0]['alias'])) {
            $fromClause = $this->parts['from'][0]['alias'].' FROM '.$this->getFromClause();
        } else {
            $fromClause = $this->parts['from'][0]['table'];
        }

        $setClause = array();

        foreach ($this->parts['set'] as $idenfier => $value) {
            $setClause[] = $this->getExpressionBuilder()->equal($idenfier, $value);
        }

        return 'UPDATE '.$fromClause.
               ' SET '.implode(', ', $setClause).
               (($this->parts['where'] !== null) ? ' WHERE '.$this->parts['where'] : null);
    }
174239
protected static function transformRow($row)
    {
        foreach ($row as $key => $value) {
            if ($value instanceof DateTime) {
                $row[$key] = $value->format('Y-m-d H:i:s');
            } else {
                if (is_object($value)) {
                    $row[$key] = (string) $value;
                } else {
                    $row[$key] = $value;
                }
            }
        }

        return $row;
    }
1324570
protected function formatWhereToNamePlaceHolder($where)
    {
        $whereStr = '';
        $whereNew = [];
        foreach ($where as $key => $value) {
            $key = trim(str_replace(['AND', '?', '='], ['', '', ''], $key));
            $whereNew[$key] = $value;
            $whereStr .= "$key = :$key,";
        }

        return [$whereNew, rtrim($whereStr, ',')];
    }
1044156
public function findOne() {
        $this->statementContext->setLimit(1);

        $statement = new SelectStatement();
        $statement->setStatementContext($this->statementContext);
        $statement->setCondition($this->condition);
        $sql = $statement->parse();

        $row = $this->connection->query($sql, $this->statementContext->getParameters());

        $this->clear();

        return $row;
    }
1034232
public function getLocalPrimaryKeys()
    {
        $cols = [];
        $localCols = $this->getLocalColumnObjects();

        foreach ($localCols as $localCol) {
            if ($localCol->isPrimaryKey()) {
                $cols[] = $localCol;
            }
        }

        return $cols;
    }
1128114
public function getWhere()
    {
        $where = $this->where;

        if (! $where) {
            return [];
        }

        foreach ($where['$or'] as &$and) {
            if (isset($and['$and']) && count($and['$and']) === 1) {
                $and = reset($and['$and']);
            }

            if (isset($and['$or']) && count($and['$or']) === 1) {
                $and = reset($and['$or']);
            }
        }

        if (count($where['$or']) === 1) {
            $where = reset($where['$or']);
        }

        return $where;
    }
343711
public function GetWhere($criteria)
	{
		if ($this->Type != self::$TYPE_SEARCH) throw new Exception('Unsupported Filter Type');
		
		// normalize property names as an array
		$propertyNames = (is_array($this->PropertyNames)) ? $this->PropertyNames : explode(',', $this->PropertyNames);
		
		$where = ' (';
		$orDelim = '';
		foreach ($propertyNames as $propName)
		{
			$dbfield = $criteria->GetFieldFromProp($propName);
			$where .= $orDelim . $criteria->Escape($dbfield) ." like ". $criteria->GetQuotedSql($this->Value) . "";
			$orDelim = ' or ';
		}
		$where .= ') ';
		
		return $where;
	}