本文整理汇总了PHP中CRUD::getModelName方法的典型用法代码示例。如果您正苦于以下问题:PHP CRUD::getModelName方法的具体用法?PHP CRUD::getModelName怎么用?PHP CRUD::getModelName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRUD
的用法示例。
在下文中一共展示了CRUD::getModelName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: detail
public static function detail($orm, $id, $fields, $writable = true, $relations = null, $relations_limit = 10)
{
// 'main' will refer to main object, and 'rel' to its relations
$main_crud = new CRUD($orm, $fields);
$main_crud->filter(array('id' => array('=', $id)));
$_SESSION['CRUDPage']['crud'][$main_crud->getHash()] = $main_crud;
$main = array('hash' => $main_crud->getHash(), 'data' => $main_crud->getSingleRowWithTitles(), 'widgeted_data' => $main_crud->getWidgets($main_crud->getSingleRawRow()), 'id' => $id, 'writable' => $writable);
// Relations
$rels = array();
if ($relations) {
$main_model = $main_crud->getOrmClone()->find_one();
$main_model_name = $main_crud->getModelName();
foreach ($relations as $relator_mtd => $settings) {
list($fields, $details_url, $add_new, $defaults, $limit) = array_merge($settings, array(null, null, null, null));
// set default values
if (is_null($add_new)) {
$add_new = true;
}
if (is_null($defaults)) {
$defaults = array();
}
$crud = new CRUD($main_model->{$relator_mtd}(), $fields);
$crud->limit($relations_limit);
// set defaults
$rel_details = CRUD::parseRelationDetails($relator_mtd . '.', $main_model_name);
$key_name = $rel_details['key1'];
$crud->setDefaults(array_merge($defaults, array($key_name => $id)));
$_SESSION['CRUDPage']['crud'][$crud->getHash()] = $crud;
$rels[$relator_mtd] = array('hash' => $crud->getHash(), 'titles' => $crud->getTitles(), 'widgets' => $crud->getWidgets(), 'limit' => $crud->getLimit(), 'page_count' => $crud->getPageCount(), 'rel_title' => ucwords(str_replace('_', ' ', $relator_mtd)), 'add_new' => $add_new, 'details_url' => $details_url);
}
}
return json_encode(array('page_type' => 'detail', 'main' => $main, 'rels' => $rels));
}