本文整理汇总了PHP中xPDOSimpleObject::getOne方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDOSimpleObject::getOne方法的具体用法?PHP xPDOSimpleObject::getOne怎么用?PHP xPDOSimpleObject::getOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDOSimpleObject
的用法示例。
在下文中一共展示了xPDOSimpleObject::getOne方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
/**
* Override getOne to get the appropriate Principal class.
*
* @param $alias
* @param null $criteria
* @param bool $cacheFlag
* @return null|xPDOObject
*/
public function &getOne($alias, $criteria = null, $cacheFlag = true)
{
$object = null;
if ($alias === 'Principal') {
if ($fkdef = $this->getFKDefinition($alias)) {
$k = $fkdef['local'];
$fk = $fkdef['foreign'];
if (isset($this->_relatedObjects[$alias])) {
if (is_object($this->_relatedObjects[$alias])) {
$object =& $this->_relatedObjects[$alias];
return $object;
}
}
if ($criteria === null) {
$criteria = array($fk => $this->get($k));
}
$fkdef['class'] = $this->get('principal_class');
if ($object = $this->xpdo->getObject($fkdef['class'], $criteria, $cacheFlag)) {
$this->_relatedObjects[$alias] = $object;
}
}
} else {
$object = parent::getOne($alias, $criteria, $cacheFlag);
}
return $object;
}
示例2: getOne
public function getOne($alias, $criteria = null)
{
if (($alias === 'Recipient' || $alias === 'Sender') && $criteria === null) {
if ($fkMeta = $this->getFKDefinition($alias)) {
if ($userid = $this->get($fkMeta['local'])) {
if ($userid < 0) {
$class = 'modWebUser';
$userid = abs($userid);
} elseif ($userid > 0) {
$class = 'modManagerUser';
}
$userTable = $this->xpdo->getTableName($class);
$sql = "SELECT * FROM {$userTable} WHERE `id` = :user_id";
$bindings = array(':user_id' => array('value' => $userid, 'type' => PDO::PARAM_INT));
$criteria = new xPDOCriteria($this->xpdo, $sql, $bindings, true);
}
}
}
return parent::getOne($alias, $criteria);
}