當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。