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


PHP Relationship::exists方法代码示例

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


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

示例1: testexists

 public function testexists()
 {
     //unset and reconnect Db to resolve mysqli fetch exeception
     global $db;
     unset($db->database);
     $db->checkConnection();
     $relationship = new Relationship();
     //test with invalid relationship
     $result = $relationship->exists('test_test', $db);
     $this->assertEquals(false, $result);
     //test with valid relationship
     $result = $relationship->exists('roles_users', $db);
     $this->assertEquals(true, $result);
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:14,代码来源:RelationshipTest.php

示例2: createRelationshipMeta

 /**
  * Populates the relationship meta for a module.
  *
  * It is called during setup/install. It is used statically to create relationship meta data for many-to-many tables.
  *
  * 	@param string $key name of the object.
  * 	@param object $db database handle.
  *  @param string $tablename table, meta data is being populated for.
  *  @param array dictionary vardef dictionary for the object.     *
  *  @param string module_dir name of subdirectory where module is installed.
  *  @param boolean $iscustom Optional,set to true if module is installed in a custom directory. Default value is false.
  *  @static
  *
  *  Internal function, do not override.
  */
 function createRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir, $iscustom = false)
 {
     //load the module dictionary if not supplied.
     if (empty($dictionary) && !empty($module_dir)) {
         if ($iscustom) {
             $filename = 'custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php';
         } else {
             if ($key == 'User') {
                 // a very special case for the Employees module
                 // this must be done because the Employees/vardefs.php does an include_once on
                 // Users/vardefs.php
                 $filename = 'modules/Users/vardefs.php';
             } else {
                 $filename = 'modules/' . $module_dir . '/vardefs.php';
             }
         }
         if (file_exists($filename)) {
             include $filename;
             // cn: bug 7679 - dictionary entries defined as $GLOBALS['name'] not found
             if (empty($dictionary) || !empty($GLOBALS['dictionary'][$key])) {
                 $dictionary = $GLOBALS['dictionary'];
             }
         } else {
             $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename);
             return;
         }
     }
     if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) {
         $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table " . $tablename . " does not exist");
         display_notice("meta data absent for table " . $tablename . " keyed to {$key} ");
     } else {
         if (isset($dictionary[$key]['relationships'])) {
             $RelationshipDefs = $dictionary[$key]['relationships'];
             $delimiter = ',';
             global $beanList;
             $beanList_ucase = array_change_key_case($beanList, CASE_UPPER);
             foreach ($RelationshipDefs as $rel_name => $rel_def) {
                 if (isset($rel_def['lhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['lhs_module'])])) {
                     $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' lhs module is missing ' . $rel_def['lhs_module']);
                     continue;
                 }
                 if (isset($rel_def['rhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['rhs_module'])])) {
                     $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' rhs module is missing ' . $rel_def['rhs_module']);
                     continue;
                 }
                 //check whether relationship exists or not first.
                 if (Relationship::exists($rel_name, $db)) {
                     $GLOBALS['log']->debug('Skipping, reltionship already exists ' . $rel_name);
                 } else {
                     //	add Id to the insert statement.
                     $column_list = 'id';
                     $value_list = "'" . create_guid() . "'";
                     //add relationship name to the insert statement.
                     $column_list .= $delimiter . 'relationship_name';
                     $value_list .= $delimiter . "'" . $rel_name . "'";
                     //todo check whether $rel_def is an array or not.
                     //for now make that assumption.
                     //todo specify defaults if meta not defined.
                     foreach ($rel_def as $def_key => $value) {
                         $column_list .= $delimiter . $def_key;
                         $value_list .= $delimiter . "'" . $value . "'";
                     }
                     //create the record. todo add error check.
                     $insert_string = "INSERT into relationships (" . $column_list . ") values (" . $value_list . ")";
                     $db->query($insert_string, true);
                 }
             }
         } else {
             //todo
             //log informational message stating no relationships meta was set for this bean.
         }
     }
 }
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:88,代码来源:SugarBean.php

示例3: createRelationshipMeta

 /**
  * Populates the relationship meta for a module.
  *
  * It is called during setup/install. It is used statically to create relationship meta data for many-to-many tables.
  *
  * 	@param string $key name of the object.
  * 	@param object $db database handle.
  *  @param string $tablename table, meta data is being populated for.
  *  @param array dictionary vardef dictionary for the object.     *
  *  @param string module_dir name of subdirectory where module is installed.
  *  @param boolean $iscustom Optional,set to true if module is installed in a custom directory. Default value is false.
  *  @static
  *
  *  Internal function, do not override.
  */
 function createRelationshipMeta($key, $db, $tablename, $dictionary, $module_dir, $iscustom = false)
 {
     global $beanList;
     //load the module dictionary if not supplied.
     if (empty($dictionary) && !empty($module_dir)) {
         if ($iscustom) {
             $filename = 'custom/modules/' . $module_dir . '/Ext/Vardefs/vardefs.ext.php';
         } else {
             if ($key == 'User') {
                 // a very special case for the Employees module
                 // this must be done because the Employees/vardefs.php does an include_once on
                 // Users/vardefs.php
                 $filename = 'modules/Users/vardefs.php';
             } else {
                 $filename = 'modules/' . $module_dir . '/vardefs.php';
             }
         }
         if (file_exists($filename)) {
             include $filename;
             // cn: bug 7679 - dictionary entries defined as $GLOBALS['name'] not found
             if (empty($dictionary) || !empty($GLOBALS['dictionary'][$key])) {
                 $dictionary = $GLOBALS['dictionary'];
             }
         } else {
             $GLOBALS['log']->debug("createRelationshipMeta: no metadata file found" . $filename);
             return;
         }
     }
     if (!is_array($dictionary) or !array_key_exists($key, $dictionary)) {
         $GLOBALS['log']->fatal("createRelationshipMeta: Metadata for table " . $tablename . " does not exist");
         display_notice("meta data absent for table " . $tablename . " keyed to {$key} ");
     } else {
         if (isset($dictionary[$key]['relationships'])) {
             $RelationshipDefs = $dictionary[$key]['relationships'];
             $beanList_ucase = array_change_key_case($beanList, CASE_UPPER);
             $seed = BeanFactory::getBean("Relationships");
             $keys = array_keys($seed->field_defs);
             foreach ($RelationshipDefs as $rel_name => $rel_def) {
                 if (isset($rel_def['lhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['lhs_module'])])) {
                     $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' lhs module is missing ' . $rel_def['lhs_module']);
                     continue;
                 }
                 if (isset($rel_def['rhs_module']) and !isset($beanList_ucase[strtoupper($rel_def['rhs_module'])])) {
                     $GLOBALS['log']->debug('skipping orphaned relationship record ' . $rel_name . ' rhs module is missing ' . $rel_def['rhs_module']);
                     continue;
                 }
                 //check whether relationship exists or not first.
                 if (Relationship::exists($rel_name, $db)) {
                     $GLOBALS['log']->debug('Skipping, relationship already exists ' . $rel_name);
                 } else {
                     $toInsert = array();
                     foreach ($keys as $key) {
                         if ($key == "id") {
                             $toInsert[$key] = create_guid();
                         } else {
                             if ($key == 'relationship_role_columns') {
                                 if (!empty($rel_def['relationship_role_columns'])) {
                                     $toInsert[$key] = json_encode($rel_def['relationship_role_columns']);
                                 } else {
                                     $toInsert[$key] = '';
                                 }
                             } else {
                                 if ($key == "relationship_name") {
                                     $toInsert[$key] = $rel_name;
                                 } else {
                                     if (isset($rel_def[$key])) {
                                         $toInsert[$key] = $rel_def[$key];
                                     }
                                 }
                             }
                         }
                         //todo specify defaults if meta not defined.
                     }
                     DBManagerFactory::getInstance()->insertParams('relationships', $seed->field_defs, $toInsert);
                     Relationship::$relCacheInternal[$rel_name] = true;
                 }
             }
         } else {
             $GLOBALS['log']->debug("createRelationshipMeta: No relationship metadata set for {$module_dir}");
         }
     }
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:97,代码来源:SugarBean.php


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