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


PHP fORM::defineActiveRecordClass方法代码示例

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


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

示例1: buildRecords

 /**
  * Recursivly builds records.
  *
  * @param array* $completed_fixtures
  *   Completed records is stored in this array
  * @param $fixture_data
  *   Build records of this fixture
  */
 private function buildRecords(&$completed_fixtures, $fixture_name, $traverse = TRUE)
 {
     if (array_key_exists($fixture_name, $completed_fixtures)) {
         return;
     }
     // Load data
     if (isset($this->fixture_data[$fixture_name]) === FALSE) {
         $this->loadFixture($fixture_name);
     }
     $class_name = fORM::classize($fixture_name);
     // If the class does not exists created it
     if (class_exists($class_name) === FALSE) {
         fORM::defineActiveRecordClass($class_name);
     }
     // Create the records
     $method_name = NULL;
     $record = NULL;
     $records = array();
     foreach ($this->fixture_data[$fixture_name] as $record_data) {
         $record = new $class_name();
         foreach ($record_data as $key => $value) {
             $method_name = 'set' . fGrammar::camelize($key, $upper = TRUE);
             $value = $this->applyHookCallbacks(self::PreSetBuildHook, $fixture_name, $key, $value);
             if ($this->isRelationshipKey($fixture_name, $key)) {
                 $related_table = $this->getRelatedTable($fixture_name, $key);
                 $required = $this->isRequiredKey($fixture_name, $key);
                 if ($traverse && array_key_exists($related_table, $completed_fixtures) === FALSE && $fixture_name !== $related_table) {
                     if (isset($value) && array_key_exists($related_table, $this->fixture_sources)) {
                         $this->buildRecords($completed_fixtures, $related_table);
                         array_unshift($this->tables_to_tear_down, $related_table);
                     }
                 }
             }
             $record->{$method_name}($value);
         }
         $record->store();
         $records[] = $record;
     }
     $completed_fixtures[$fixture_name] = fRecordSet::buildFromArray($class_name, $records);
 }
开发者ID:mblarsen,项目名称:ffixture,代码行数:48,代码来源:fFixture.php


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