本文整理汇总了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);
}