<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ### 說明 >[info] 模型是用來處理業務數據,邏輯的。 模型是對應著數據中的表的,主要是對數據的增刪改查進行操作的。具體請看 [模型定義](http://www.hmoore.net/manual/thinkphp5_1/354041) >[info] #### 開始模型類的開發 在無限極分類當中,我們只用到了一個模型類,```Cate.php```,位置位于:```application\index\model\Cate.php``` **代碼如下**: ``` <?php /** * Created by PhpStorm. * User: ye21st * Email: ye21st@gmail.com * Date: 2018/1/23 * Time: 16:50 */ namespace app\index\model; use think\Model; /** * 欄目模型類 * Class Cate * @package app\index\model */ class Cate extends Model { /** * 模型的初始化方法,可以用來書寫前置或后置方法 */ protected static function init() { Cate::event('before_delete',function(){ return false; }); } /** * 讓欄目樹 按照降序排序 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function catetree(){ $cateres=$this->order('sort desc')->select(); return $this->sort($cateres); } /** * 排序方法 * @param $data * @param int $pid * @param int $level * @return array */ public function sort($data,$pid=0,$level=0){ static $arr=array(); foreach ($data as $k => $v) { if($v['pid']==$pid){ $v['level']=$level; $arr[]=$v; $this->sort($data,$v['id'],$level+1); } } return $arr; } /** * 通過ID 獲得子節點信息 * @param $cateid * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function getchilrenid($cateid){ $cateres=$this->select(); return $this->_getchilrenid($cateres,$cateid); } /** * 遞歸方法 * @param $cateres * @param $cateid * @return array */ public function _getchilrenid($cateres,$cateid){ static $arr=array(); foreach ($cateres as $k => $v) { if($v['pid'] == $cateid){ $arr[]=$v['id']; $this->_getchilrenid($cateres,$v['id']); } } return $arr; } } ``` >[info] 至此,模型類開發完畢
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看