<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                ## :-: 模型 所有模型均需要放置在application\\common\\model目錄下,以便各個模塊使用 所有模型均要繼承\\app\\common\\model\\Common模型,如: ~~~ <?php namespace app\common\model; /** * 測試模型 */ class Test extends Common { public function test(){} } ~~~ 所有模型默認具有以下通用方法 ## 列表通用模型方法 ~~~ /** * 通用查詢列表方法 * @param $post * @return mixed * @throws \think\exception\DbException */ public function tableData($post) { if(isset($post['limit'])){ $limit = $post['limit']; }else{ $limit = config('paginate.list_rows'); } $tableWhere = $this->tableWhere($post); $list = $this->field($tableWhere['field'])->where($tableWhere['where'])->order($tableWhere['order'])->paginate($limit); $data = $this->tableFormat($list->getCollection()); //返回的數據格式化,并渲染成table所需要的最終的顯示數據類型 $re['code'] = 0; $re['msg'] = ''; $re['count'] = $list->total(); $re['data'] = $data; return $re; } ~~~ ~~~ /** * 根據輸入的查詢條件,返回所需要的where * @author sin * @param $post * @return mixed */ protected function tableWhere($post) { $result['where'] = []; $result['field'] = "*"; $result['order'] = []; return $result; } /** * 數據查詢后格式化方法 * @param $list * @return mixed */ protected function tableFormat($list) { return $list; } ~~~ ## 軟刪除 模型文件中需要增加以下定義: ~~~ use SoftDelete; //軟刪除標記字段 protected $deleteTime = 'isdel'; ~~~ 定義好之后,即可使用以下方法對數據進行軟刪除 ~~~ // 軟刪除 User::destroy(1); // 真實刪除 User::destroy(1,true); $user = User::get(1); // 軟刪除 $user->delete(); // 真實刪除 $user->delete(true); ~~~ ## 添加更新時間自動填充 ~~~ protected $autoWriteTimestamp = true; //創建時間 protected $createTime = 'ctime'; //更新時間 protected $updateTime = 'utime'; ~~~ ## 數據庫表文件定義規范 1. 有自增主鍵的表,主鍵建議使用id 作為表主鍵名稱,其它地方表中調用該表主鍵時為 “表名\_id” 2. 創建時間統一為 ctime 3. 更新時間統一為 utime 4. 軟刪除標記字段統一為 isdel 5. 類型字段,例如:性別、狀態等建議使用tinyint類型 6. 表排序規則統一為:utf8mb4\_general\_ci 7. 所有表使用InnoDB作為數據庫引擎 表中定義的類型,建議都在模型中以常量的形式定義出來,例如: const MARKETABLE\_UP = 1; //上架 const MARKETABLE\_DOWN = 2;//下架 const VIRTUAL\_YES = 2;//虛擬商品 const VIRTUAL\_NO = 1;//普通商品 在使用時盡量避免直接使用1、2、3這樣的數字,盡量使用 模型::常量進行調用,例如 self::MARKETABLE\_DOWN 或 $goodsModel = new Goods(); $goodsModel::MARKETABLE\_DOWN
                  <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>

                              哎呀哎呀视频在线观看