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


PHP CRUD::parseRelationDetails方法代码示例

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


在下文中一共展示了CRUD::parseRelationDetails方法的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));
 }
开发者ID:cal127,项目名称:phpcrud,代码行数:33,代码来源:Page.php


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