本文整理匯總了PHP中Dao::getReference方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dao::getReference方法的具體用法?PHP Dao::getReference怎麽用?PHP Dao::getReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Dao
的用法示例。
在下文中一共展示了Dao::getReference方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGettingReferenceCachesTheReference
/**
* @covers Dao::getReference
*/
public function testGettingReferenceCachesTheReference()
{
$reference = $this->getMockForAbstractClass('BasicDaoReference', array(), '', false);
$this->dao->expects($this->once())->method('getUserReference')->will($this->returnValue($reference));
self::assertEquals($reference, $this->dao->getReference('user'));
self::assertEquals($reference, $this->dao->getReference('user'));
}
示例2: get
/**
* Gets the value of the $data array and returns it.
* If the value is a DATE or DATE_WITH_TIME type, it returns a Date Object.
* If the attribute name is not defined in the attributes list, the record checks if a function with
* the same name but an underscore in front exists, and
* _theAttributeName
*
* @param string $attributeName
* @return mixed
*/
public function get($attributeName)
{
$attributes = $this->dao->getAttributes();
if (array_key_exists($attributeName, $attributes)) {
if ($attributes[$attributeName] !== Dao::REFERENCE) {
$value = $this->getDirectly($attributeName);
} else {
// It's a reference
$reference = $this->dao->getReference($attributeName);
return $reference->getReferenced($this, $attributeName);
}
} elseif (array_key_exists($attributeName, $this->dao->getAdditionalAttributes())) {
$value = array_key_exists($attributeName, $this->data) ? $this->data[$attributeName] : null;
} elseif (method_exists($this, '_' . $attributeName)) {
return $this->getComputedAttribute($attributeName);
} else {
$this->triggerUndefinedAttributeError($attributeName);
return null;
}
$attributeType = $this->getAttributeType($attributeName);
if ($value !== null && ($attributeType === Dao::DATE || $attributeType === Dao::DATE_WITH_TIME)) {
$value = new Date($value, $attributeType === Dao::DATE_WITH_TIME);
}
return $value;
}