0

I am trying to do a mysql sort that displays 0 first and then by the smallest number.

$query = "SELECT DISTINCT id FROM `items` WHERE `name`='Mag' AND `var`='Bl' ORDER BY atrow + 0 ASC"

How to write it in medoo?

$item = $database->select("items", "@id", [
    "var[=]" => "Bl",
    "name[=]" => "Mag",
    "ORDER" => ["atrow" => "ASC"]
]);

This is not working properly.

ruleboy21
  • 5,510
  • 4
  • 17
  • 34

1 Answers1

0

You need a two tiered sort here. Assuming we use the following raw MySQL query:

SELECT DISTINCT id
FROM item
ORDER BY row != 0, row;

PHP code:

$item= $database->select("items", "@id", [ "ORDER" => Medoo::raw("`row` != 0, `row`")]);
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360