本文整理汇总了PHP中Mapper::getIdField方法的典型用法代码示例。如果您正苦于以下问题:PHP Mapper::getIdField方法的具体用法?PHP Mapper::getIdField怎么用?PHP Mapper::getIdField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mapper
的用法示例。
在下文中一共展示了Mapper::getIdField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
* @param array $aggregateProto Entity ids or prototypes array
* @param Mapper $mapper Mapper Object
* @param null|string $cacheKey Cache key for aggregate
* @param bool $loadEntities Should load aggregate entities
* @throws BaseException
*/
public function __construct(array $aggregateProto, Mapper $mapper, $cacheKey = null, $loadEntities = false)
{
$this->mapper = $mapper;
$this->cacheKey = $cacheKey;
$this->entities = array();
$idField = $this->mapper->getIdField();
foreach ($aggregateProto as $entityProto) {
if (false === is_array($entityProto)) {
$entityProto = array($idField => $entityProto);
} else {
if (false === array_key_exists($idField, $entityProto)) {
throw new BaseException('Entity proto does not contain id');
}
}
$this->listEntityId[] = $entityProto[$idField];
if (count($entityProto) > 1) {
$entity = $mapper->createEntity($entityProto);
$this->entities[$entity->getId()] = $entity;
$this->loadedListEntityId[$entity->getId()] = $entity->getId();
}
}
if ($loadEntities && false === $this->isAllEntitiesLoaded()) {
$this->loadEntities();
}
}
示例2: getId
/**
* Return entity id
* @return int
*/
public function getId()
{
return $this->proto[$this->mapper->getIdField()];
}