select - how to convert count(*) and group by queries to yii and fetch data from it -


i want convert query in yii

select count(*) cnt, date(dt) tbl_log status=2 group date(dt)  

and fetch data that. try command (dt datetime field):

$criteria = new cdbcriteria(); $criteria->select = 'count(*) cnt, date(dt)'; $criteria->group = 'date(dt)'; $criteria->condition = 'status= 2'; $visit_per_day = $this->findall($criteria); 

but no data fetch! wath can data?

probably see no data because need assign data model attributes doesn't exist.

$criteria = new cdbcriteria(); $criteria->select = 'count(*) cnt, date(dt) datevar'; $criteria->group = 'date(dt)'; $criteria->condition = 'status= 2'; $visit_per_day = $this->findall($criteria); 

this means model must have attributes cnt , datevar in order show data. if need custom query check hearaman's answer.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -