本文整理汇总了PHP中DB_DataObject::links方法的典型用法代码示例。如果您正苦于以下问题:PHP DB_DataObject::links方法的具体用法?PHP DB_DataObject::links怎么用?PHP DB_DataObject::links使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB_DataObject
的用法示例。
在下文中一共展示了DB_DataObject::links方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: links
/**
* Override standard links() method, to make sure it reads correctly data from links.ini
* file even if DataObjects uses prefix.
*
* @access public
* @see DB_DataObject::links()
* @return array
*/
function links()
{
$links = parent::links();
if (empty($this->_prefix)) {
return $links;
} else {
$prefixedLinks = array();
if ($GLOBALS['_DB_DATAOBJECT']['LINKS'][$this->_database][$this->_tableName]) {
$links = $GLOBALS['_DB_DATAOBJECT']['LINKS'][$this->_database][$this->_tableName];
foreach ($links as $k => $v) {
// add prefix
$prefixedLinks[$k] = $this->_prefix . $v;
}
}
return $prefixedLinks;
}
}
示例2: generateParents
/**
* Generate parents records using the relationship defined in links.ini file
*
* @param DB_DataObject $do
*/
function generateParents(&$do)
{
$links = $do->links();
foreach ($links as $foreignKey => $linkedTableField) {
if (!empty($do->{$foreignKey})) {
// parent is already set
continue;
}
list($linkedTable, $linkedField) = explode(':', $linkedTableField);
$table = $do->getTableWithoutPrefix($linkedTable);
$linkedPrimaryKeyVal = isset($do->{$foreignKey}) ? $do->{$foreignKey} : null;
if (!empty($this) && is_a($this, 'DataGenerator')) {
$do->{$foreignKey} = $this->addAncestor($table, $linkedPrimaryKeyVal);
} else {
$do->{$foreignKey} = DataGenerator::addAncestor($table, $linkedPrimaryKeyVal);
}
}
}
示例3: links
public function links()
{
// avoid those annoying PEAR::DB strict standards warnings it causes
$old = error_reporting();
error_reporting(error_reporting() & ~E_STRICT);
$res = parent::links();
// reset
error_reporting($old);
return $res;
}