{@inheritDoc}
@return ORM
500429
public function create(\Asgard\Entity\Definition $definition, DataMapperInterface $dataMapper, $locale=null, $prefix=null) {
		return new ORM($definition, $dataMapper, $locale=null, $prefix=null, $this->paginatorFactory);
	}
585195
public function object() : EmbeddedValueObjectDefiner
    {
        return new EmbeddedValueObjectDefiner($this->orm,
            function (callable $mapperLoader, string $issetColumnName = null, bool $isUnique) {
                // Use null object mapper as parent to load the columns
                /** @var IEmbeddedObjectMapper $tempMapper */
                $tempMapper  = $mapperLoader(new NullObjectMapper());
                $columnNames = [];
                $embeddedObjectTable = $tempMapper->getDefinition()->getTable();
                
                if ($issetColumnName && !$embeddedObjectTable->hasColumn($issetColumnName)) {
                    $this->definition->addColumn(new Column($issetColumnName, new Boolean()));
                }

                foreach ($embeddedObjectTable->getColumns() as $column) {
                    $this->definition->addColumn($issetColumnName ? $column->asNullable() : $column);
                    $columnNames[] = $column->getName();
                }


                if ($isUnique) {
                    $this->definition->unique($this->definition->getTableName() . '_' . implode('_', $columnNames) . '_unique_index')
                        ->on($columnNames);
                }

                call_user_func($this->callback, function (
                    $idString,
                    Table $parentTable,
                    IObjectMapper $parentMapper
                ) use (
                    $mapperLoader,
                    $issetColumnName
                ) {
                    return new EmbeddedObjectRelation($idString, $mapperLoader($parentMapper), $issetColumnName);
                });
            });
    }
1105133
public function orx($value)
    {
        if(!is_array($value)) {
            // get arguments 
            $value = func_get_args();
        }
        // Convert all values to 
        $conds = array_map(function($v) {
                if(is_string($v) && $this->getQueryParser()) {
                    return $this->getQueryParser()->parseExpression($v);
                } else if(!$v instanceof Expr\ConditionalExpression) {
                    throw new \InvalidArgumentException('');
                } 
                return $v;
            }, $value);

        //return new Expr\OrX($conds);
        return new Expr\LogicalExpression($conds, Expr\LogicalExpression::TYPE_OR);
    }
1232140
public function query() : Builder
	{
		if (trim($conditions = $this->conditions) !== '') {
			$this->builder->where('condition', 'LIKE', $conditions);
		}

		return $this->builder;
	}
53248
public static function with($model)
    {
        $data = static::model()->findAll();

        $idKey = null;
        $whereIn = [];
        foreach ($data as $key => $value) {
            $idKey = $value->primaryKey;
            $whereIn[] = $value->{$value->primaryKey};
        }

        $associatedModel = new $model();
        $associatedData = $associatedModel
            ->where(static::getForeignKey(static::model()->tableName), 'IN', implode(',', $whereIn))
            ->findAll();

        $data = static::buildRelations($data, $associatedModel, $associatedData);

        return $data;
    }
1364182
public function getModels()
    {
        try {
            $q = $this->createQueryBuilder('l')
                    ->where('l._site IS NULL')
                    ->orderBy('l._label', 'ASC')
                    ->getQuery();

            return $q->getResult();
        } catch (\Doctrine\ORM\NoResultException $e) {
            return;
        } catch (Exception $e) {
            return;
        }
    }
46274
public function collection() : EmbeddedCollectionDefiner
    {
        return new EmbeddedCollectionDefiner(
            $this->orm,
            function (callable $mapperLoader, $tableName, $primaryKeyName, $foreignKeyName) {
                call_user_func($this->callback, function (
                    $idString,
                    Table $parentTable,
                    IObjectMapper $parentMapper
                ) use (
                    $mapperLoader,
                    $tableName,
                    $primaryKeyName,
                    $foreignKeyName
                ) {
                    return new EmbeddedCollectionRelation(
                        $idString,
                        $mapperLoader($parentMapper),
                        $parentTable->getName(),
                        $this->orm->getNamespace() . $tableName,
                        $parentTable->getPrimaryKeyColumn()->withName($primaryKeyName),
                        new Column($foreignKeyName, PrimaryKeyBuilder::primaryKeyType()),
                        $parentTable->getPrimaryKeyColumn()
                    );
                });
            }
        );
    }
1135693
public function transform(\Orm\Model $model)
	{
		$properties = $model->list_properties();

		$data = $model->to_array(false, false, true);
		$data = Arr::subset($data, array_keys($properties));
		$data = Arr::flattenAssoc($data, '.');

		// Check for options and set value
		foreach ($properties as $key => $value)
		{
			if ( ! empty($data) and $options = Arr::get($value, 'options', false))
			{
				$data[$key] = $options[$data[$key]];
			}
		}

		if ($this->actions)
		{
			$data['action'] = $this->actions($model);
		}

		return array_values($data);
	}
252755
public function get($offset = null)
    {
        if (!func_num_args()) {
            return $this->_data;
        }
        $keys = is_array($offset) ? $offset : explode('.', $offset);
        if (!$keys) {
            throw new ORMException("Invalid empty index `" . $offset . "` for collection.");
        }

        $name = array_shift($keys);
        if ($keys) {
            if (!array_key_exists($name, $this->_data)) {
                throw new ORMException("Missing index `" . $name . "` for collection.");
            }
            $value = $this->_data[$name];
            if (!$value instanceof DataStoreInterface) {
                throw new ORMException("The field: `" . $name . "` is not a valid document or entity.");
            }
            return $value->get($keys);
        }
        if (!array_key_exists($name, $this->_data)) {
            throw new ORMException("Missing index `" . $name . "` for collection.");
        }
        return $this->_data[$name];
    }
421389
public function search($q)
    {
        /* @var \Doctrine\ODM\MongoDB\Query\Builder $qb */
        $qb = $this->repository->createQueryBuilder();
        $qb->field('title')->equals(new \MongoRegex('/' . addslashes($q) . '/i'));
        $cursor = $qb->getQuery()->execute();

        $adapter = new DoctrineMongoCursor($cursor);
        parent::__construct($adapter);

        return $this;
    }
997061
public function createQuery()
    {
        $query = \Parable\ORM\Query::createInstance();
        $query->setTableName($this->getTableName());
        return $query;
    }
1022465
public static function limit($params) {
        $limit = $params['args'][0];
        $ormObject = !is_null($params['ormObject']) ? $params['ormObject'] : ORM::for_table($params['table']);
        
        return $ormObject->limit($limit);
    }
503220
public function query() : Builder
	{
		if (! is_null($this->min) && ! is_null($this->max)) {
			$this->builder->whereBetween('price', [$this->min, $this->max]);
		}

		if (! is_null($this->min) && is_null($this->max)) {
			$this->builder->where('price', '>=', $this->min);
		}

		if (is_null($this->min) && ! is_null($this->max)) {
			$this->builder->where('price', '<=', $this->max);
		}

		return $this->builder;
	}
1027136
public function getOrphans()
    {
        $table = ORM::getTable($this->getTable()->getPlugin(), 'Image');
        $q = $table->createSelectQuery();
        $e = $q->expr;
        $q->where($e->lAnd(
            $e->eq('section', $q->bindValue($this->id, null, PDO::PARAM_INT)),
            $e->eq('groupId', $q->bindValue(0, null, PDO::PARAM_INT))
        ));
        return $table->loadFromQuery($q);
    }
983911
public function build()
    {
        $cm = $this->builder->getClassMetadata();
        if ($this->generatedValue) {
            $cm->setIdGeneratorType(constant('Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_' . $this->generatedValue));
        }
        if ($this->version) {
            $cm->setVersionMapping($this->mapping);
        }
        $cm->mapField($this->mapping);
        if ($this->sequenceDef) {
            $cm->setSequenceGeneratorDefinition($this->sequenceDef);
        }
        return $this->builder;
    }
902478
public function or_where($column, $op = null, $value = null)
	{
		if($column instanceof \Closure)
		{
			$this->or_where_open();
			$column($this);
			$this->or_where_close();
			return $this;
		}

		if (is_array($column))
		{
			foreach ($column as $key => $val)
			{
				if (is_array($val))
				{
					$this->or_where($val[0], $val[1], $val[2]);
				}
				else
				{
					$this->or_where($key, '=', $val);
				}
			}
		}
		else
		{
			if(func_num_args() === 2)
			{
				$value = $op;
				$op = '=';
			}
			$this->_where[] = array('OR' => array($column, $op, $value));
		}
		return $this;
	}
341642
public function createQuery()
    {
        $query = $this->persistenceManager->createQueryForType($this->entityClassName);
        if ($this->defaultOrderings !== []) {
            $query->setOrderings($this->defaultOrderings);
        }
        return $query;
    }