本文整理汇总了PHP中EntityRepository::createObjectFromValues方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityRepository::createObjectFromValues方法的具体用法?PHP EntityRepository::createObjectFromValues怎么用?PHP EntityRepository::createObjectFromValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityRepository
的用法示例。
在下文中一共展示了EntityRepository::createObjectFromValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
/**
* Load all items defined by fluent.
*
*
* @return DbRecordCollection
*/
public function load()
{
if ($this->isLoaded()) {
return $this;
}
if (!$this->isLoadable()) {
throw new Exception('This collection is not loadable! Maybe items were set manualy before load!');
}
if (!$this->query) {
// pokud neni fluent set, nastav defaultni
$this->query();
#throw new Exception('Fluent is not set');
}
foreach ($this->query->toArray() as $values) {
$this->repository->createObjectFromValues($values);
// map by IdentityMap
if ($this->options['mapped']) {
$item = $class::identity()->map($item);
}
$this->append($item);
}
$this->setLoaded(true);
return $this;
}
示例2: findBy
/**
* Fetch single row from database based on defined fluent and obligatory conditions defined in array.
*
* @param mixed $primary
* @return DbRecord
*/
public function findBy(array $conditions)
{
$metadata = $this->repository->getMetadata();
foreach ($conditions as $key => $value) {
$this->where('#.' . $key . ' = %' . $metadata->getType($key), $value);
}
$values = $this->limit(1)->toArray();
/*
//no more exceptions on not founded item in dtb
if ( !$values ) {
throw new NotFoundException("Item was not found!");
}
*/
if ($values) {
return $this->repository->createObjectFromValues($values[0]);
}
return NULL;
}