catfan / Medoo

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

WHERE clause with ORDER BY & LIMIT don't work ! #846

Closed jogratna closed 5 years ago

jogratna commented 5 years ago

Describe the bug A clear and concise description of what the bug is. simple where clause with order by and limit don't work. There is serious bug in the code. Information

Detail Code $transacts=$_dbObj->debug()->select("tbltransactions","fldrate", [ "AND" => [ "flduid" => $uid, "fldstock_id" => $data["fldstock_id"], "fldtype" => 1 ]],[ "LIMIT" => [0,1], "ORDER" => [ "flddate" => "DESC" ] ] );

gives this output;

SELECT fldrate FROM tbltransactions WHERE (flduid = 1 AND fldstock_id = 1 AND fldtype = 1)

Expected output

SELECT fldrate FROM tbltransactions WHERE (flduid = 1 AND fldstock_id = 1 AND fldtype = 1) ORDER BY 'flddate' DESC LIMIT 0,1

catfan commented 5 years ago

Just check out the documentation seriously https://medoo.in/api/select. The conditions and LIMIT/ORDER are together in the same array.

[
    "AND" => [
        "flduid" => $uid,
        "fldstock_id" => $data["fldstock_id"],
        "fldtype" => 1
    ],
    "LIMIT" => [0,1],
    "ORDER" => ["flddate" => "DESC"]
]