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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 模版模型介紹 項目開發中,模版調用數據內容,經常要操作數據庫,如:調用最新文章列表,推薦內容,以及首頁或者封面頁面內容集合的調用。模版模型就是為了方便操作數據庫查詢進行的封裝,可以直接在模版中調用數據庫的內容,無需再經過控制器的處理。 # 模版模型標簽調用說明 模塊名:model 可用參數: `table`:要查詢的主表比如 `table = "user"` ~~~ {%mdoel data="userlist",table="user"%} ~~~ > 查詢user表內的內容,`返回userlist` 列表集合。 `join` :{Object} 要組合的查詢語句,默認為 `LEFT JOIN` ~~~ {%model data="data",table="question_user",cache='1000',order="question_count DESC",alias="a",limit="10",join='{"member": {"join": "left","as":"b","on": ["a.uid", "b.id"]}}'%} ~~~ `field` {String} 設置要查詢的字段,必須是字符串 ~~~ //設置要查詢的字符串,字符串方式,多個用逗號隔開 {%mdoel data="userlist",table="user",field="name,age"%} ~~~ `fieldReverse`:{String} 反選字段,即查詢的時候不包含這些字段 ~~~ //設置要查詢的字符串,字符串方式,多個用逗號隔開 {%mdoel data="userlist",table="user",field="name,age"%} ~~~ `alias`:{String} 表別名 ~~~ {%model data="data",table="question_user",cache='1000',order="question_count DESC",alias="a",limit="10",join='{"member": {"join": "left","as":"b","on": ["a.uid", "b.id"]}}'%} ~~~ `limit`(offset, length) :offset {Number} 設置查詢的起始位置 length {Number} 設置查詢的數據長度 ~~~ {%mdoel data="userlist",table="user",limit="10"%} ~~~ `where` {json字符串} where 條件 ~~~ {%mdoel data="userlist",table="user",where='{"id":10}',limit="10"%} ~~~ `order` {String} 排序方式 ~~~ {%mdoel data="userlist",table="user",where='{"id":10}',order="id DESC",limit="10"%} ~~~ cache {Number} 緩存有效時間,單位為秒,建議1000秒 ~~~ {%mdoel data="userlist",table="user",where='{"id":10}',order="id DESC",limit="10",cache='1000%} ~~~ ## 代碼例子 ~~~ {%model data="data",table="question_user",cache='1000',order="question_count DESC",alias="a",limit="10",join='{"member": {"join": "left","as":"b","on": ["a.uid", "b.id"]}}'%} {%if data.length>0%} <div class="box-inner nopadding margin-bottom-20"> <h3> <a class="pull-right size-11 text-warning" href="#">更多</a> 熱門用戶 </h3> <div class="" > {%for user in data%} <div class="clearfix margin-bottom-10"><!-- squared item --> <img class="thumbnail pull-left rounded" src="/uc/index/avatar/uid/{{user.uid}}" width="40" height="40" alt="" /> <h4 class="size-14 nomargin noborder nopadding bold"><a href="#">{{user.username}}</a></h4> <span class="size-12 text-muted">{{user.question_count}} 個問題, {{user.agree_count}} 次贊同</span> </div><!-- /squared item --> {%endfor%} </div> </div> {%endif%} ~~~
                  <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>

                              哎呀哎呀视频在线观看