So I write:
$top=Watch::find() ->select(['fl_serial.*,fl_watch.*,COUNT(fl_watch.active=1) AS total_count']) ->joinWith('serial','fl_watch.id_serial=serial.id') ->groupBy('fl_watch.id_serial') ->orderBy(['total_count'=>SORT_DESC]) ->limit(10) ->all(); Then process it like this:
foreach($top as $post) { $posts[]=$post->total_count; } I receive:
Getting unknown property: common \ models \ Watch :: total_count
How to handle COUNT( * ) AS total_count correctly?