asked    Herbert     2018-10-22       php       118 view        1 Answer

[SOLVED] How display (hierarchical) years and months of my articles creating (PHP, Yii2)?

I have articles table in my DB:

id(int), title(varchar), text(text), created_date(date)

I need display all months and years of articles creating with count of articles like this:

2018
Jan (5)
Mar (7)
Jul (5)
Dec (1)

2017
Feb (12)
Sep (3)

2016 
Aug (13)
Sep (6)
Nov (2)

How can I do this with Yii2?

  1 Answer  

        answered    Nelly     2018-10-22      

Hi I dont now how to do this in yii but the basic query to access to this data ,It would be something like this.

First execte this SQL query

SELECT YEAR(created_date),MONTH(created_date), COUNT(id) TotalCount
FROM articles
GROUP BY YEAR(created_date), MONTH(created_date);

This will return you a result what you need , count all articles . by month and year.

Then what do yo need do now is implements this query into you project Yii2 and parse and split how you need





Your Answer





 2018-10-22         Marcus

Sqlite getting the latest record for this table

I can't figure out what I am doing wrong here. I am querying sqlite table the to get the latest record for each College but the result is not completely accurate. Below is the source table:College Status Date"UTAR "CERTIFIED" "07/30/2018""UTA" "CERTIFIED" "03/19/2018""UTD" "CERTIFIED" "06/08/2018""UTEL" "CERTIFIED" "03/13/2018""UTSA" "CERTIFIED" "02/06/2018""UTT" "CERTIFIED" "03/14/2018""UTPB" "CERTIFIED" "07/23/2018""UTRG" "CERTIFIED" "04/12/2018""UTAR" "CERTIFIED" "05/31/2017""UTA" "CERTIFIED" "03/02/2017""UTD" "CERTIFIED" "04/13/2017""UTEL" "...
 sql                     2 answers                     108 view
 2018-10-22         Kyle

How to rewrite implicit joins to explicit joins?

I'm having some trouble re-writing these JOINS using explicit joins. I'm trying to understand how this is accomplished. Here is the original query using implicit joins that I've inherited:FROM prod.f31122 t, prod.f4801 wo, prod.f30008 r, prod.f0101 abWHERE t.wtdoco = wo.wadoco(+) and t.wtmmcu = wo.wammcu(+) and t.wtmmcu = r.iwmcu and t.wtan8 = ab.aban8I've tried the following, but I'm getting different result sets. The same count, but the result set is incorrect (likely an issue with my groupings which aren't displayed). Here is my translati...
 sql                     3 answers                     111 view
 2018-10-22         Perry

Two databases with same tables and column names, How to pull out one column with similar data while all the other columns showing the differences?

I have 2 databases named 'OK' and 'TX' with same table named 'E_Model' and columns like: 'Product_ID' , 'Description', 'Warranty' and 'Category'I want to have the list of Product ID's which both the tables have and want to know the difference in all the other column at the same time. Desired result should be like:**'*Database' 'Product_ID' , 'Description', 'Warranty' 'Category'***OK LB9456 COFFEE 436 NULL 10 TX LB9456 TOASTER 956 1 12OK QR3300 APPLE 31 3 15TX ...
 sql-server                     1 answers                     106 view