catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.83k stars 1.15k forks source link

ORDER BY has bugs #469

Closed leoncool closed 8 years ago

leoncool commented 8 years ago

With V1.1.2 and V1.1.3 there is a bug with ORDER, DESC and ASC will not add to the SQL query string.

For example: $trans=$database->select(TABLE_FinanceTrans,"",["AND"=>$filter,"ORDER"=>TABLE_Finance_Trans.".createdat DESC","LIMIT"=>[($pageNumber)$itemsPerPage,$itemsPerPage]]); This is create query: SELECT * FROM "finance_trans" ORDER BY "finance_trans"."created_at" LIMIT 0,10

DESC does not show up in SQL query, please fix. Thanks!

rakshazi commented 8 years ago

@catfan affected me too

rakshazi commented 8 years ago

@leoncool

Workaround:

<?php
$database->select(TABLE_Finance_Trans, "", [
    "AND"=>$filter,
    "ORDER"=> [TABLE_Finance_Trans.".created_at" => DESC"], //Just use [$field => $direction] array
    "LIMIT"=>[($pageNumber)$itemsPerPage,$itemsPerPage]]);
iNilo commented 8 years ago

Also having this issue.

catfan commented 8 years ago

The ORDER syntax is updated since v1.1.

http://medoo.in/api/where