当前位置: 首页>>代码示例>>PHP>>正文


PHP DataModel::s_graph方法代码示例

本文整理汇总了PHP中DataModel::s_graph方法的典型用法代码示例。如果您正苦于以下问题:PHP DataModel::s_graph方法的具体用法?PHP DataModel::s_graph怎么用?PHP DataModel::s_graph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataModel的用法示例。


在下文中一共展示了DataModel::s_graph方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Graph

 /**
  *
  */
 function __construct($pb_dont_cache = false)
 {
     // is the graph already in memory?
     if (!$pb_dont_cache && DataModel::$s_graph) {
         return;
     }
     // is there an on-disk cache of the internal graph?
     if (is_object($vo_cache = $this->_getCacheObject())) {
         if ($va_graph = $vo_cache->load('ca_datamodel_graph')) {
             $this->opo_graph = new Graph($va_graph);
             return;
         }
     }
     $o_config = Configuration::load();
     if ($vs_data_model_path = $o_config->get("data_model")) {
         // is it cached in memory?
         if ($_DATAMODEL_CACHE[$vs_data_model_path]) {
             $this->opo_graph = $_DATAMODEL_CACHE[$vs_data_model_path];
             return true;
         }
         $o_datamodel = Configuration::load($vs_data_model_path);
         $this->opo_graph = new Graph();
         # add tables
         if (!($va_tables = $o_datamodel->getAssoc("tables"))) {
             $va_tables = array();
         }
         foreach ($va_tables as $vs_table => $vn_num) {
             $this->opo_graph->addNode($vs_table);
             $this->opo_graph->addAttribute("num", $vn_num, $vs_table);
             $this->opo_graph->addNode("t#" . $vn_num);
             $this->opo_graph->addAttribute("name", $vs_table, "t#" . $vn_num);
         }
         # add relationships
         if (!($va_relationships = $o_datamodel->getList("relationships"))) {
             $va_relationships = array();
         }
         foreach ($va_relationships as $vs_relationship) {
             $va_keys = preg_split("/[\t ]*=[\t ]*/", $vs_relationship);
             $vn_num_keys = sizeof($va_keys);
             switch ($vn_num_keys) {
                 case 2:
                     $vs_key1 = $va_keys[0];
                     $va_tmp = preg_split('/[ ]+/', $va_keys[1]);
                     $vs_key2 = $va_tmp[0];
                     list($vs_table1, $vs_field1) = explode(".", $vs_key1);
                     list($vs_table2, $vs_field2) = explode(".", $vs_key2);
                     $vn_weight = isset($va_tmp[1]) && intval($va_tmp[1]) > 0 ? intval($va_tmp[1]) : 10;
                     break;
                 default:
                     die("Fatal error: syntax error in datamodel relationship specification: '{$vs_relationship}'\n");
                     break;
             }
             if (!$this->opo_graph->hasNode($vs_table1)) {
                 die("Fatal error: invalid table '{$vs_table1}' in relationship in datamodel definition\n");
             }
             if (!$this->opo_graph->hasNode($vs_table2)) {
                 die("Fatal error: invalid table '{$vs_table2}' in relationship in datamodel definition\n");
             }
             if (!($va_attr = $this->opo_graph->getAttributes($vs_table1, $vs_table2))) {
                 $va_attr = array();
                 $this->opo_graph->addRelationship($vs_table1, $vs_table2);
             }
             $va_attr["relationships"][$vs_table1][$vs_table2][] = array($vs_field1, $vs_field2);
             $va_attr["relationships"][$vs_table2][$vs_table1][] = array($vs_field2, $vs_field1);
             $va_attr['WEIGHT'] = $vn_weight;
             $this->opo_graph->setAttributes($va_attr, $vs_table1, $vs_table2);
         }
         if (is_object($vo_cache)) {
             $vo_cache->save(DataModel::$s_graph = $this->opo_graph->getInternalData(), 'ca_datamodel_graph', array('ca_datamodel_cache'));
         }
     }
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:75,代码来源:Datamodel.php


注:本文中的DataModel::s_graph方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。