Closed MrMarci666 closed 6 years ago
Hi guys, I want to get an array from Offers from my db. i have "price" and "profit" field. I can order by profit OR price, but i want to order by "profit * price".
Here is my code:
$containers = $database->select(TABLE_OFFERS, "*", [ "AND" => ["cid" => $database->select(TABLE_PARTNERS, "cid", ['OR'=>['zip'=>$_SESSION['container']['googlePlace3_postal_code'],'city'=>$_SESSION['container']['googlePlace3_locality']]]), "mid" => (int)$material['id']], "GROUP" => 'size', "ORDER" => ['price'=>'ASC'] ]);
"ORDER" => ["price * profit" => "ASC"]
doesn't work. :)
Please help me.
Thank you
I'm not sure multiply two columns will work on SQL or other database, but you can use Medoo::raw object for this case.
Medoo::raw
"ORDER" => Medoo::raw("<price> * <profit> ASC")
Hi guys, I want to get an array from Offers from my db. i have "price" and "profit" field. I can order by profit OR price, but i want to order by "profit * price".
Here is my code:
"ORDER" => ["price * profit" => "ASC"]
doesn't work. :)
Please help me.
Thank you