本文整理匯總了PHP中Dao::findById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dao::findById方法的具體用法?PHP Dao::findById怎麽用?PHP Dao::findById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Dao
的用法示例。
在下文中一共展示了Dao::findById方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: findById
/**
* Get a single instance of an entity by its database record id
*
* @param int $id The id of the entity
*
* @return BaseEntityAbstract
*/
public function findById($id)
{
$results = Dao::findById($this->_query->setSelectActiveOnly(false), $id);
$this->resetQuery();
return $results;
}
示例2: loadManyToOne
/**
* Lazy load a many-to-one relationship
*
* @param string $property The property that we are trying to load
*
* @return BaseEntityAbstract
*/
protected function loadManyToOne($property)
{
$this->__loadDaoMap();
if (is_null($this->{$property})) {
//if the proerty is allow to have null value, then let it be
if (DaoMap::$map[strtolower(get_class($this))][$property]['nullable']) {
$this->{$property} = null;
return $this;
}
//if the property is one of these, as when we are trying to save them, we don't have the iniated value
if (in_array($property, array('createdBy', 'updatedBy'))) {
$this->{$property} = Core::getUser();
} else {
throw new Exception('Property (' . get_class($this) . '::' . $property . ') must be initialised to integer or proxy prior to lazy loading.', 1);
}
}
// Load the DAO map for this entity
$cls = DaoMap::$map[strtolower(get_class($this))][$property]['class'];
if (!$this->{$property} instanceof BaseEntityAbstract) {
throw new DaoException('The property(' . $property . ') for "' . get_class($this) . '" is NOT a BaseEntity!');
}
$qry = new DaoQuery($cls);
$qry->setSelectActiveOnly(false);
$this->{$property} = Dao::findById($qry, $this->{$property}->getId());
return $this;
}