Medoo查询条件+排序的几个例子

Medoo框架查询指定条件并排序的实例:

$database->debug()->select("book", "*", ["ORDER" => ["date" => "DESC"]]);

查询语句:SELECT * FROM `book` ORDER BY `date` DESC

$database->debug()->select("book", "*", ["view" => "1","ORDER" => ["date" => "DESC"]]);

查询语句:SELECT * FROM `book` WHERE `view` = '1' ORDER BY `date` DESC

$database->debug()->select("book", "*", [
        "AND" => [
            "type" => $_GET["type"],
            "view" => "1"
        ],"ORDER" => ["date" => "DESC"]
    ]);

查询语句:SELECT * FROM `book` WHERE (`type` = '1' AND `view` = '1') ORDER BY `date` DESC

希望可供借鉴。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章