Код: Выделить всё
$newsFromTwoTables = ThisDay::find()
->where(
new Expression(
"day = :dateDay"
. " AND id_region = :id_region"
. " AND month = :month", [":dateDay" => $dateDay,
":month" => $currentMoth,
":id_region" => REGION_ID]))
->orderBy("news_date DESC")
->joinWith('news')
->where(
new Expression("EXTRACT(DAY FROM cdate) = :userDay "
. "AND id_region = :id_region "
. "AND EXTRACT(MONTH FROM cdate) = :userMonth "
. "AND EXTRACT(YEAR FROM cdate) "
. "AND status > :stat AND n.id NOT IN"
. " (SELECT id_news FROM this_day)", [":userDay" => $dateDay,
":userMonth" => $currentMoth,
":id_region" => REGION_ID,
":stat" => 1]))
//новости с самым высоким рейтингом
->with("rating nr")
->orderBy("nr.rate DESC")
->limit(4 - ThisDay::find()
->where(
new Expression(
"day = :dateDay"
. " AND id_region = :id_region", [":dateDay" => $dateDay,
":id_region" => REGION_ID]))
->count())
->orderBy("cdate_int DESC")
->groupBy("EXTRACT(YEAR FROM cdate)")
->all();
Как можно исправить запрос на выборку так, чтобы избежать этой ошибки?