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