本文整理汇总了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;
}