久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    <legend id='SL8fg'><style id='SL8fg'><dir id='SL8fg'><q id='SL8fg'></q></dir></style></legend>
    <i id='SL8fg'><tr id='SL8fg'><dt id='SL8fg'><q id='SL8fg'><span id='SL8fg'><b id='SL8fg'><form id='SL8fg'><ins id='SL8fg'></ins><ul id='SL8fg'></ul><sub id='SL8fg'></sub></form><legend id='SL8fg'></legend><bdo id='SL8fg'><pre id='SL8fg'><center id='SL8fg'></center></pre></bdo></b><th id='SL8fg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='SL8fg'><tfoot id='SL8fg'></tfoot><dl id='SL8fg'><fieldset id='SL8fg'></fieldset></dl></div>
  1. <small id='SL8fg'></small><noframes id='SL8fg'>

  2. <tfoot id='SL8fg'></tfoot>
      <bdo id='SL8fg'></bdo><ul id='SL8fg'></ul>

      Yii:獲取每月熱門用戶和年末熱門用戶的SQL查詢

      Yii: SQL query for getting the top users for every month and top users at the end of year(Yii:獲取每月熱門用戶和年末熱門用戶的SQL查詢)
    1. <legend id='AGdLL'><style id='AGdLL'><dir id='AGdLL'><q id='AGdLL'></q></dir></style></legend>

      <small id='AGdLL'></small><noframes id='AGdLL'>

      1. <tfoot id='AGdLL'></tfoot>

          <i id='AGdLL'><tr id='AGdLL'><dt id='AGdLL'><q id='AGdLL'><span id='AGdLL'><b id='AGdLL'><form id='AGdLL'><ins id='AGdLL'></ins><ul id='AGdLL'></ul><sub id='AGdLL'></sub></form><legend id='AGdLL'></legend><bdo id='AGdLL'><pre id='AGdLL'><center id='AGdLL'></center></pre></bdo></b><th id='AGdLL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AGdLL'><tfoot id='AGdLL'></tfoot><dl id='AGdLL'><fieldset id='AGdLL'></fieldset></dl></div>

              <bdo id='AGdLL'></bdo><ul id='AGdLL'></ul>

                <tbody id='AGdLL'></tbody>
                本文介紹了Yii:獲取每月熱門用戶和年末熱門用戶的SQL查詢的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我是一個 yiibie,我有一個問題,我有一個名為 user_join_event 的表,它有 id(PK) ngo_id(FK) event_id(FK) date_created date_modified 作為對象,我想獲得每個月的 5 個用戶 ID(在此表中重復(fù)次數(shù)最多).像1月前5名用戶,2月前5名用戶等等,然后是這張表中年底前5名的用戶,就像一年結(jié)束后,它應(yīng)該再次給出整個月的前5名用戶.請幫我解決這個問題,如何為此編寫SQL查詢,謝謝.

                 公共函數(shù) actionAllstats(){$this->layout='main';$user=UserJoinEvent::model()->findAll(array('條件' =>'YEAR(date_created)=:year 和 MONTH(date_created)=:month','參數(shù)' =>數(shù)組(':year'=>2015, ':month'=>$yourMonth),'選擇'='=>'user_id','組'=>'user_id','訂單'=>'COUNT(*) DESC','限制' =>5));$this->render('allstats', array("user"=>$user));}

                這是我的視圖文件

                <?phpforeach($user 作為 $show){for($i = 1 ; $i <=12 ; $i++){if($yourMonth == $i){$model = User::model()->findByAttributes(array('id'=>$show->user_id,));如果(isset($模型)){回聲'<h3>'.$show->user_id .' - ' .$model->用戶名.'</h3>';}別的 {回聲'<h3>'.$show->user_id .' - 未找到用戶名</h3>';}}}}?>

                解決方案

                你可以起訴這個查詢獲得用戶的年度

                 $user=UserJoinEvent::model()->findAll(array('條件' =>'YEAR(date_create)=:year','參數(shù)' =>數(shù)組(':year'=>2015)'選擇'='=>'user_id','組'=>'user_id','訂單'=>'COUNT(*) DESC','限制' =>5));

                并且對于這個月,您可以使用此查詢從 1 到 12 進行循環(huán),并使用循環(huán)中的值設(shè)置 $yourMonth

                 $user=UserJoinEvent::model()->findAll(array('條件' =>'YEAR(date_create)=:year 和 MONTH(date_create)=:month','參數(shù)' =>數(shù)組(':year'=>2015, ':month'=>$yourMonth)'選擇'='=>'user_id','組'=>'user_id','訂單'=>'COUNT(*) DESC','限制' =>5));

                控制器動作

                公共函數(shù) actionAllstats(){$this->layout='main';$myCurrYear = 日期(Y")$userYear=UserJoinEvent::model()->findAll(array('條件' =>'YEAR(date_create)=:year','參數(shù)' =>數(shù)組(':year'=>$myCurrYear)'選擇'='=>'user_id','組'=>'user_id','訂單'=>'COUNT(*) DESC','限制' =>5));$this->render('allstats', array("userYear"=>$userYear));}

                查看

                這個視圖不是基于良好的實踐,因為在視圖中使用了對模型的訪問.是為了引導(dǎo)您了解與問題相關(guān)的一些問題的嘗試.

                <?php//這十二個月for($month = 1 ; $month <=12 ; $month++) {<div>$user=UserJoinEvent::model()->findAll(array('條件' =>'YEAR(date_created)=:year 和 MONTH(date_created)=:month','參數(shù)' =>數(shù)組(':year'=>2015, ':month'=>$month),'選擇'='=>'user_id','組'=>'user_id','訂單'=>'COUNT(*) DESC','限制' =>5));foreach($user as $show) {$model = User::model()->findByAttributes(array('id'=>$show->user_id,));如果(isset($模型)){回聲'<h3>'.$show->user_id .' - ' .$model->用戶名.'</h3>';}別的 {回聲'<h3>'.$show->user_id .' - 未找到用戶名</h3>';}}

                }?><div><?php//年份foreach($userYear as $show) {$model = User::model()->findByAttributes(array('id'=>$show->user_id,));如果(isset($模型)){回聲'<h3>'.$show->user_id .' - ' .$model->用戶名.'</h3>';}別的 {回聲'<h3>'.$show->user_id .' - 未找到用戶名</h3>';}}?>

                I am a yiibie, I have a question that I have a table named user_join_event which has id(PK) ngo_id(FK) event_id(FK) date_created date_modified as objects, and I want to get the 5 users Id's(which are repeated the most in this table) for every month. Like January top 5 users, Feb top 5 users and so on and then the top 5 users at the end of the year from this table, like once the year is completed it should give again the top 5 users from all over the month. Please help me with this, how to write an SQL query for this, thank you.

                 public function actionAllstats()
                            {
                
                        $this->layout='main';
                        $user=UserJoinEvent::model()->findAll(array(
                            'condition' => 'YEAR(date_created)=:year and MONTH(date_created)=:month',
                            'param' => array(':year'=>2015, ':month'=>$yourMonth),
                            'select'=>'user_id',
                            'group'=>'user_id',
                            'order'=>'COUNT(*) DESC',
                            'limit' =>  5
                         ));  
                        $this->render('allstats', array("user"=>$user));
                            }
                

                and this is my view file

                <div>
                    <?php
                
                        foreach($user as $show)
                        {
                            for($i = 1 ; $i <=12 ; $i++)
                            {
                                if($yourMonth == $i)
                                {
                                    $model = User::model()->findByAttributes(array('id'=>$show->user_id,));
                           if (isset($model)) 
                               {
                               echo '<h3>' . $show->user_id .  ' - ' . $model->username . '</h3>';
                           } 
                           else {
                               echo '<h3>' . $show->user_id .  ' - Username not found</h3>';
                           } 
                                }
                            }
                
                        }
                
                        ?>
                    </div>
                

                解決方案

                For the Year you can sue this query for getting the users

                       $user=UserJoinEvent::model()->findAll(array(
                            'condition' => 'YEAR(date_create)=:year',
                            'params' => array(':year'=>2015)
                            'select'=>'user_id',
                            'group'=>'user_id',
                            'order'=>'COUNT(*) DESC',
                            'limit' =>  5
                         ));  
                

                and for the month you can do a loop from 1 to 12 using this query and set $yourMonth withe the value in loop

                       $user=UserJoinEvent::model()->findAll(array(
                            'condition' => 'YEAR(date_create)=:year and MONTH(date_create)=:month',
                            'params' => array(':year'=>2015, ':month'=>$yourMonth )
                            'select'=>'user_id',
                            'group'=>'user_id',
                            'order'=>'COUNT(*) DESC',
                            'limit' =>  5
                         ));  
                

                Controller action

                public function actionAllstats()
                {
                
                    $this->layout='main';
                    $myCurrYear = date("Y")
                    $userYear=UserJoinEvent::model()->findAll(array(
                        'condition' => 'YEAR(date_create)=:year',
                        'params' => array(':year'=>$myCurrYear)
                        'select'=>'user_id',
                        'group'=>'user_id',
                        'order'=>'COUNT(*) DESC',
                        'limit' =>  5
                     ));  
                    $this->render('allstats', array("userYear"=>$userYear));
                }
                

                View

                This view in not based on good pratice, because use access to model inside a view. is a trial for lead you to understand some of the problem related with question.

                <?php    // this for the twelve month
                
                    for($month = 1 ; $month <=12 ; $month++) {
                    <div>
                        $user=UserJoinEvent::model()->findAll(array(
                            'condition' => 'YEAR(date_created)=:year and MONTH(date_created)=:month',
                            'params' => array(':year'=>2015, ':month'=>$month),
                            'select'=>'user_id',
                            'group'=>'user_id',
                            'order'=>'COUNT(*) DESC',
                            'limit' =>  5
                         ));    
                        foreach($user as $show) {
                            $model = User::model()->findByAttributes(array('id'=>$show->user_id,));
                            if (isset($model)) {
                                echo '<h3>' . $show->user_id .  ' - ' . $model->username . '</h3>';
                            } 
                             else {
                                echo '<h3>' . $show->user_id .  ' - Username not found</h3>';
                            } 
                        }
                    </div>            
                    }
                ?>
                
                
                <div>   
                    <?php // the for the year 
                        foreach($userYear as $show) {
                            $model = User::model()->findByAttributes(array('id'=>$show->user_id,));
                            if (isset($model)) {
                                echo '<h3>' . $show->user_id .  ' - ' . $model->username . '</h3>';
                            } 
                             else {
                                echo '<h3>' . $show->user_id .  ' - Username not found</h3>';
                            } 
                        }
                    ?>
                </div>
                

                這篇關(guān)于Yii:獲取每月熱門用戶和年末熱門用戶的SQL查詢的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                相關(guān)文檔推薦

                SQL query to get all products, categories and meta data woocommerce/wordpress(獲取所有產(chǎn)品、類別和元數(shù)據(jù)的 SQL 查詢 woocommerce/wordpress)
                Can I figure out a list of databases and the space used by SQL Server instances without writing SQL queries?(我可以在不編寫 SQL 查詢的情況下找出數(shù)據(jù)庫列表和 SQL Server 實例使用的空間嗎?) - IT屋-程序員軟件開發(fā)
                How to create a login to a SQL Server instance?(如何創(chuàng)建對 SQL Server 實例的登錄?)
                How to know the version and edition of SQL Server through registry search(如何通過注冊表搜索知道SQL Server的版本和版本)
                WinForms application design - moving documents from SQL Server to file storage(WinForms 應(yīng)用程序設(shè)計——將文檔從 SQL Server 移動到文件存儲)
                How to use MySQL in WSL (Windows Subsystem for Linux)?(如何在 WSL(Linux 的 Windows 子系統(tǒng))中使用 MySQL?)
                <legend id='qtAex'><style id='qtAex'><dir id='qtAex'><q id='qtAex'></q></dir></style></legend>
                  <bdo id='qtAex'></bdo><ul id='qtAex'></ul>
              • <i id='qtAex'><tr id='qtAex'><dt id='qtAex'><q id='qtAex'><span id='qtAex'><b id='qtAex'><form id='qtAex'><ins id='qtAex'></ins><ul id='qtAex'></ul><sub id='qtAex'></sub></form><legend id='qtAex'></legend><bdo id='qtAex'><pre id='qtAex'><center id='qtAex'></center></pre></bdo></b><th id='qtAex'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qtAex'><tfoot id='qtAex'></tfoot><dl id='qtAex'><fieldset id='qtAex'></fieldset></dl></div>

                <tfoot id='qtAex'></tfoot>

                  1. <small id='qtAex'></small><noframes id='qtAex'>

                  2. 主站蜘蛛池模板: 做a视频| 精品久草 | 欧美在线综合 | 国产精品久久久久久久久久了 | 成人乱人乱一区二区三区软件 | 亚洲综合第一页 | 国产aⅴ| 国产成人在线一区 | 久久免费精品 | 国产精品久久福利 | 亚洲福利在线视频 | 亚洲一区精品在线 | 欧美a在线| 国产精品久久亚洲 | 亚洲国产精品久久 | 欧美精品99| 欧美成人精品一区二区男人看 | 日本一级淫片免费啪啪3 | 久久精品视频一区二区 | 性一交一乱一伦视频免费观看 | 国产免费一区二区三区网站免费 | 一级毛片免费 | 成人免费视频网 | 毛片久久久 | 九九热视频这里只有精品 | 欧美成年黄网站色视频 | 久久久久国产一区二区三区 | 中文av字幕| 欧美日韩国产精品一区二区 | 九色在线观看 | 国产成人亚洲精品自产在线 | 二区成人 | 一区二区在线看 | 黄色日批视频 | 国产一区不卡 | 国产欧美一区二区三区久久手机版 | 毛片韩国 | 久久精品小视频 | 国产91网站在线观看 | 成人一区二区在线 | 欧美男人亚洲天堂 |