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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                收藏表結構 | 字段 | 含義 | | --- | --- | | id | 主鍵 | | user_id | 用戶id | | title| 收藏內容的標題 | | url | 收藏內容的原文地址,不帶域名 | | description | 收藏內容的描述 | | table_name | 收藏實體以前所在表不帶前綴 | | object_id | 收藏內容里原來的主鍵id | | create_time | 收藏時間 | 加入數據后如圖所示: ![](https://box.kancloud.cn/252413563974d66266ec1d79e707f74d_1119x79.png) 前端代碼: ~~~ <a href="{:url('user/favorite/add')}" class="js-favorite-btn" data-title="{:base64_encode($article.post_title)}" data-url="{:cmf_url_encode('portal/Article/index',array('id'=>$article['id']))}" data-table="portal_post" data-id="{$article['id']}" > <i class="fa fa-star-o"></i> </a> ~~~ 推送到后臺其實是由js完成的 js代碼如下 public\static\js\frontend.js ~~~ var $js_favorite_btn = $('a.js-favorite-btn'); if ($js_favorite_btn.length) { Wind.use('noty', function () { $js_favorite_btn.on('click', function (e) { e.preventDefault(); var $this = $(this), href = $this.prop('href'), url = $this.data("url"), id = $this.data("id"), table = $this.data('table'), title = $this.data("title"), description = $this.data("description"); $.post(href, { id: id, table: table, url: url, title: title, description: description }, function (data) { if (data.code == 1) { if (data.msg) { noty({ text: data.msg, type: 'success', layout: 'center', callback: { afterClose: function () { if (data.url) { location.href = data.url; } } } }); } } else if (data.code == 0) { noty({ text: data.msg, type: 'error', layout: 'center', callback: { afterClose: function () { if (data.url) { location.href = data.url; } } } }); } }, "json"); }); }); } ~~~ 邏輯很清晰,阻止按鈕默認動作,ajax傳輸數據,成功后重載頁面 * * * * * 后臺邏輯主要集中在 \app\user\controller\FavoriteController.php \app\user\model\UserFavoriteModel.php 這兩個文件 * * * * * 分析 一個用戶可以收藏多篇文章 一篇文章可以被多個用戶收藏 我們的數據表中因為多了諸如 description title url這樣的字段,對于某一用戶的收藏文章,就可以用 ~~~ $userQuery = Db::name("UserFavorite"); $favorites = $userQuery->where(['user_id' => $userId])->order('id desc')->paginate(10); ~~~ 來查詢并列出表格,這樣節省了再次查詢文章表所需要的sql
                  <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>

                              哎呀哎呀视频在线观看