Home  >  Article  >  Backend Development  >  How can I set DESC for sorting in php's medoo select?

How can I set DESC for sorting in php's medoo select?

WBOY
WBOYOriginal
2016-08-18 09:16:271740browse

Use (MD() is a method I wrote to get medoo objects)

<code>MD()->debug()->select('items',[
    '[>]items_pic'=>['id'=>'item_id']
],['items.id','items_pic.src'],[
    'AND'=>[
        'items.uid'=>19,
        'items.is_delete'=>0
    ],
    'ORDER'=>'items.id DESC'
])
</code>

will output this sql statement, which is different from the Chinese document. The last order by does not include DESC. Why is this? The actual data found is indeed not in reverse order

SELECT "items"."id","items_pic"."src" FROM "items" LEFT JOIN "items_pic" ON "items"."id" = "items_pic"."item_id" WHERE "items"."uid " = 19 AND "items"."is_delete" = 0 ORDER BY "items"."id"

Reply content:

Use (MD() is a method I wrote to get medoo objects)

<code>MD()->debug()->select('items',[
    '[>]items_pic'=>['id'=>'item_id']
],['items.id','items_pic.src'],[
    'AND'=>[
        'items.uid'=>19,
        'items.is_delete'=>0
    ],
    'ORDER'=>'items.id DESC'
])
</code>

will output this sql statement, which is different from the Chinese document. The last order by does not include DESC. Why is this? The actual data found is indeed not in reverse order

SELECT "items"."id","items_pic"."src" FROM "items" LEFT JOIN "items_pic" ON "items"."id" = "items_pic"."item_id" WHERE "items"."uid " = 19 AND "items"."is_delete" = 0 ORDER BY "items"."id"

"ORDER" => ["item.id"=>"DESC"]

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn