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


PHP Library::convertToTree方法代码示例

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


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

示例1: getComments

 public function getComments($menuId)
 {
     $rows = $this->db->query("SELECT * FROM comment WHERE menu_id=%i", $menuId)->fetchAll();
     foreach ($rows as &$row) {
         $row['comment_id'] = (int) $row['comment_id'];
     }
     array_unshift($rows, new \Dibi\Row(array('id' => 0, 'comment_id' => null)));
     $tree = $this->library->convertToTree($rows, 'id', 'comment_id', 'comments');
     $tree[0]['comments'] = $this->library->removeKeys($tree[0]['comments'], 'comments');
     return $tree[0]['comments'];
 }
开发者ID:claryaldringen,项目名称:CMS,代码行数:11,代码来源:CommentModel.php

示例2: getMenu

 public function getMenu($languageId = null)
 {
     if (empty($languageId)) {
         $languageId = $this->languageId;
     }
     if (!isset($this->menu[$languageId])) {
         $sql = "SELECT m.id,m.menu_id,m.type_id,t.text,t.url,visibility,IF(url IS NULL AND sort = 0, 255, sort) AS sort\n \t\t\tFROM [menu] m\n\t\t\tLEFT JOIN [name_has_text] nht ON m.name_id=nht.name_id AND language_id=%i\n\t\t\tLEFT JOIN [text] t ON t.id=nht.text_id\n\t\t\tWHERE site_id=%i\n\t\t\tORDER BY m.visibility,[sort],[id]";
         $rows = $this->db->query($sql, $languageId, $this->siteId)->fetchAll();
         foreach ($rows as &$row) {
             $row['menu_id'] = (int) $row['menu_id'];
         }
         array_unshift($rows, new \Dibi\Row(array('id' => 0, 'menu_id' => null)));
         $tree = $this->library->convertToTree($rows, 'id', 'menu_id', 'items');
         $tree[0]['items'] = $this->library->removeKeys($tree[0]['items'], 'items');
         $this->menu[$languageId] = $tree;
     }
     return $this->menu[$languageId];
 }
开发者ID:claryaldringen,项目名称:CMS,代码行数:18,代码来源:MenuModel.php

示例3: getMenu

 public function getMenu($type = 'visible')
 {
     if (!isset($this->menu[$type])) {
         $sql = "SELECT m.id,m.menu_id,m.type_id AS type,t.text,t.url,m.visibility FROM [menu] m\n\t\t\tJOIN [name_has_text] nht ON m.name_id=nht.name_id AND language_id=%i\n\t\t\tJOIN [text] t ON t.id=nht.text_id\n\t\t\tWHERE site_id=%i AND m.visibility = %s\n\t\t\tORDER BY [sort],[id]";
         $rows = $this->db->query($sql, $this->getLanguageId(), $this->siteId, $type)->fetchAll();
         foreach ($rows as &$row) {
             $row['menu_id'] = (int) $row['menu_id'];
         }
         if ($type == 'visible') {
             array_unshift($rows, new DibiRow(array('id' => 0, 'menu_id' => null)));
             $tree = $this->library->convertToTree($rows, 'id', 'menu_id', 'items');
             $tree[0]['items'] = $this->library->removeKeys($tree[0]['items'], 'items');
             $this->menu[$type] = $tree;
         } else {
             $this->menu[$type] = $rows;
         }
     }
     return $this->menu[$type];
 }
开发者ID:claryaldringen,项目名称:Backend,代码行数:19,代码来源:MenuModel.php


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