catfan / Medoo

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

Sort by ORDER DESC/ASC not working in Version 1.1.3 #477

Closed merajmehri closed 8 years ago

merajmehri commented 8 years ago

For example: I have a table "post" with value :

| id(int) | title(varchar(255)) | content(text) |
---------------------------------------
|     1   |   title1    |    this a sample text 1    |
---------------------------------------
|     2   |   title2    |    this a sample text 2    |
---------------------------------------
|     3   |   title3    |    this a sample text 3    |
---------------------------------------
|     4   |   title4    |    this a sample text 4    |
---------------------------------------
|     5   |   title5    |    this a sample text 5    |
---------------------------------------
|     6   |   title6    |    this a sample text 6    |
`---------------------------------------`

And my example code:

<?php
$obj = new medoo();
$post = $obj->select("post","*",[
     "ORDER" => "post.id DESC/ASC",
     "LIMIT" => 6
]);
print_r($post);

When set DESC must be show 6 - 5 - 4 - 3 - 2 - 1(sort info of id 6 to 1) When set ASC must be show 1 - 2 - 3 - 4 - 5 -6 (sort info of id 1 to 6) Don't show info with correctly sort why? ?>

ghost commented 8 years ago

code should be this:

$obj = new medoo(); $post = $obj->select("post","*",[ "ORDER" => [ "id" => "ASC" ], "LIMIT" => 6 ]); print_r($post);

sigurdbuchberger commented 8 years ago

thanks @jmyeom that worked :)

merajmehri commented 8 years ago

Thanks @jmyeom worked :)