本文整理匯總了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;
}