$query = Article::find()
->joinWith('cities ci')
->where([
'ci.region_id' => $regionID
])
->orderBy('RAND()')
->limit(12);
SELECT post.*
FROM (
SELECT id
FROM post
ORDER BY RAND()
LIMIT 10
)
AS ids JOIN post ON post.id = ids.id