Ищем объекты.

@param array $conditions
@param bool $returnBuilder

@return mixed
762067
public function searchItems(array $conditions, bool $returnBuilder = false)
    {
        $builder = $this->getItemsQuery([])->where($conditions);

        if ($returnBuilder) {
            return $builder;
        }

        return $builder->get();
    }
1108829
public function findWhere(array $conditions, $limit = null)
    {
        foreach ($conditions as $field => $criteria) {
            if (strpos($field, '.') === false) {
                $field = $this->table . '.' . $field;
            }
            $this->qb->where($field, $criteria);
        }

        if ($result = $this->qb
            ->from($this->table)
            ->get($limit)) {
            $this->result = new DataObjects\Result($result, $this);
            $this->result->setInfo($result->getInfo());

            if ($limit == 1) {
                return $this->result->first();
            }

            return $this->result;
        }

        return false;
    }
1078367
protected function _format_return(array $calls, $return_type)
	{
		switch ($return_type)
		{
			case 'array':
				return $calls;
				break;
			case 'json':
				return json_encode($calls);
				break;
			case 'none':
				return;
			case 'serialized':
				return serialize($calls);
				break;
			case 'string':
				$str = '';
				foreach ($calls as $call)
				{
					$str .= $call;
				}
				return $str;
				break;
			default:
				return $calls;
				break;
		}

		return false;
	}
145070
public function getConditionSql(array $sql, array $where, string $conditionType): array
    {
        if (empty($where)) {
            return $sql;
        }
        foreach ($where as $index => $item) {
            if ($item instanceof RawExp) {
                if ($index == 0) {
                    $sql[] = $conditionType . ' ' . $item->getValue();
                    continue;
                }
                $sql[] = $item->getValue();
                continue;
            }
            [$type, $conditions] = $item;
            if (!$index) {
                $whereType = $conditionType;
            } else {
                $whereType = strtoupper($type);
            }
            if ($conditions[0] instanceof RawExp) {
                $sql[] = $whereType . ' ' . $conditions[0]->getValue();
                continue;
            }
            [$leftField, $operator, $rightField] = $conditions;
            $leftField = $this->quoter->quoteName($leftField);
            [$rightField, $operator] = $this->getRightFieldValue($rightField, $operator);

            $sql[] = sprintf('%s %s %s %s', $whereType, $leftField, $operator, $rightField);
        }

        return $sql;
    }
548532
private function buildEventAggregate(array $rows, $returnType)
    {
        if ($returnType === self::RETURN_AS_ARRAY) {
            return $this->buildEventAggregateAsArray($rows);
        }

        return $this->buildEventAggregateAsObject($rows);
    }
1261578
public static function findOne(array $conditions = [])
    {
        $data = static::entity()->getDatabase()->findOne(static::$collection, $conditions);

        if (!$data) {
            return null;
        }

        $instance = new static;
        $data['__webiny_db__'] = true;
        $instance->populate($data);

        return static::entity()->add($instance);
    }
622812
private static function _getByPosition($position, $conditions=null)
    {
        self::_checkLoaded();

        $builder          = self::_makeBuilder();
        $builder->fields  = self::extractColumns();
        $builder->order   = $position=="first" ? self::getOrder() : self::getReversedOrder();
        $builder->where   = self::_extractWhereConditions($conditions);
        $vals             = self::extractWhereValues($conditions);

        $cls  = get_called_class();
        $stmt = self::executePrepared($builder, $vals);
        $data = $stmt->fetch(\PDO::FETCH_ASSOC);

        if (!$data) {
            return null;
        }
        return new $cls($data);
    }
29058
protected function getListProductClassField(array $conditions = array())
    {
        $conditions += $this->query_filter;
        $conditions['product_class_id'] = $this->data_product_class['product_class_id'];

        return (array) $this->product_class_field->getList($conditions);
    }
1367267
public function _insert(Model $model, $fields, $returnId)
    {
        $qb = $this->connection->createQueryBuilder();

        $qb->insert($model->getMeta()->getDbTable());

        /** @var $field Field */
        foreach ($fields as $name => $field) {
            $value = $this->prepareValueForDatabaseSave(
                $field,
                $field->preSave($model, true)
            );

            $qb->setValue($field->getColumnName(), $qb->createNamedParameter($value));
        }

        // save to db
        $qb->execute();

        if ($returnId) {
            return $this->connection->lastInsertId();
        }
    }
1312146
private function buildEventAggregate(array $events, $returnType)
    {
        if ($returnType === self::RETURN_AS_ARRAY) {
            return $this->buildEventAggregateAsArray($events);
        }

        return $this->buildEventAggregateAsObject($events);
    }
699465
public static function all($conditions=null)
    {
        self::_checkLoaded();

        $builder = self::_makeBuilder();
        $builder->fields  = self::extractColumns();
        $vals    = null;

        if ($conditions) {
            $builder->where = self::_extractWhereConditions($conditions);
            $vals           = self::extractWhereValues($conditions);
        }
        return new Collection($builder, $vals, get_called_class());
    }
153732
public function objectMethods($builder)
    {
        $this->builder = $builder;
        $script = '';
        $this->getFieldTranslation($script);    //методы переводов указанного поля

        return $script;
    }
1204786
public function findOneBy(array $conditions)
    {
        $s = $this->selector()->one();
        foreach ($conditions as $column => $value) {
            $s->where($column, '=', $value);
        }

        return $s->execute();
    }
790870
protected function fetch($entityName, array $conditions, $result = false)
    {
        $query = $this->storage->read($entityName);

        foreach ($conditions as $field => $values) {
            $query->where($field, $values);
        }

        if (!$result) {
            return $query->execute();
        }

        foreach ($this->relations as $relation) {
            $query->with($relation->name());
        }

        foreach ($this->conditions as $condition) {
            $query->where($condition[0], $condition[1], $condition[2], $condition[3]);
        }

        foreach ($this->orders as $order) {
            $query->order($order[0], $order[1]);
        }

        if ($this->limit !== null || $this->offset !== null) {
            $query->limit($this->limit, $this->offset);
        }

        return $query->execute();
    }
700719
protected function _operator($operator, $conditions, &$states)
    {
        if (isset($this->_operators[$operator])) {
            $config = $this->_operators[$operator];
        } elseif (substr($operator, -2) === '()') {
            $op = substr($operator, 0, -2);
            if (isset($this->_operators[$op])) {
                return '(' . $this->_operator($op, $conditions, $states) . ')';
            }
            $config = ['builder' => 'function'];
        } else {
            throw new SqlException("Unexisting operator `'{$operator}'`.");
        }
        $parts = $this->_conditions($conditions, $states);

        $operator = (is_array($parts) && next($parts) === 'NULL' && isset($config['null'])) ? $config['null'] : $operator;
        $operator = $operator[0] === ':' ? strtoupper(substr($operator, 1)) : $operator;

        if (isset($config['builder'])) {
            $builder = $this->_builders[$config['builder']];
            return $builder($operator, $parts);
        }
        if (isset($config['format'])) {
            return sprintf($config['format'], join(", ", $parts));
        }
        return join(" {$operator} ", $parts);
    }
232105
public function andHaving(...$conditions): Select
    {
        $condition = $this->prepareCondition($conditions);

        if ($this->having instanceof CompositeBuilder
            && $this->having->getType() === 'AND') {
            $this->having->addPart($condition);
        } else {
            $this->having = new CompositeBuilder([$this->having, $condition]);
        }
        return $this;
    }
947881
public function findWhere($criteria, $returnType = Table::RETURN_MODEL) {
        if (!is_array($criteria)) {
            $criteria = array($criteria);
        }
        $return = $this->select($criteria, $returnType);
        if (is_a($return, 'DBScribe\Table')) $return = $return->execute();
        return $return;
    }