本文整理汇总了PHP中Centurion_Db::setReferences方法的典型用法代码示例。如果您正苦于以下问题:PHP Centurion_Db::setReferences方法的具体用法?PHP Centurion_Db::setReferences怎么用?PHP Centurion_Db::setReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Centurion_Db
的用法示例。
在下文中一共展示了Centurion_Db::setReferences方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initDbTable
/**
* Initialize DbTable for each loaded module.
*
* @return void
*/
protected function _initDbTable()
{
$cache = $this->_getCache('core');
if (!($references = $cache->load('references_apps'))) {
$this->bootstrap('FrontController');
$this->bootstrap('db');
$this->bootstrap('modules');
$front = $this->getResource('FrontController');
$modules = $front->getControllerDirectory();
$references = array();
$moduleEnabled = Centurion_Config_Manager::get('resources.modules');
foreach ($modules as $moduleName => $module) {
if (!in_array($moduleName, $moduleEnabled)) {
continue;
}
$dbTableDir = realpath($module . '/../models/DbTable');
if (!file_exists($dbTableDir)) {
continue;
}
$dir = new Centurion_Iterator_DbTableFilter($dbTableDir);
foreach ($dir as $fileInfo) {
$filename = $fileInfo->getFilenameWithoutExtension();
$className = sprintf('%s_Model_DbTable_%s', ucfirst($moduleName), $filename);
$model = Centurion_Db::getSingletonByClassName($className);
$meta = $model->getMeta();
$metaData = $model->info('metadata');
foreach ($model->getReferenceMap() as $key => $referenceMap) {
$refTableClass = $referenceMap['refTableClass'];
$referencedModel = Centurion_Db::getSingletonByClassName($refTableClass);
$plural = true;
if (isset($metaData[$referenceMap['columns']]['UNIQUE']) && $metaData[$referenceMap['columns']]['UNIQUE'] == true) {
$plural = false;
}
if ($plural) {
$dependentTableKey = $meta['verbosePlural'];
} else {
$dependentTableKey = $meta['verboseName'];
}
if (array_key_exists($dependentTableKey, $referencedModel->getDependentTables())) {
continue;
}
if (!array_key_exists($refTableClass, $references)) {
$references[$refTableClass] = array();
}
$references[$refTableClass][$dependentTableKey] = $className;
}
}
}
$cache->save($references, 'references_apps');
}
Centurion_Db::setReferences($references);
}