SELECT
product.price,
product.id,
product.slug,
discount.price,
IFNULL(discount.price, product.price) AS price_finish
FROM product
LEFT JOIN discount ON discount.id=(
SELECT MAX(discount.id)
FROM discount
WHERE discount.product_id=product.id
AND discount.status=1
)
WHERE product.status=1
ORDER BY price_finish DESC
Model::find()->select(['id', .... , 'example'])->asArray()->all();
$result = [];
foreach (Model::find()->each() as $model) {
array_push($result, [
'id' => $model->id,
'example' => $model->example,
........
]);
}