catfan / Medoo

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

Why ASC -DESC are case sensitive ? (RE: #687) #696

Closed lamuzzachiodi closed 3 years ago

lamuzzachiodi commented 6 years ago

Sorry for open a new issue but you closed #687 without chance of replication. The point is that your reason ("will be better readability") isn't enough. It's just common practice but not mandatory to use uppercase. And even if followed your preference, in my case the parameters are not generated by me but by third-party code (https://datatables.net) in lowercase.
Finally, this does not require much only to change a line, for example elseif ( strcasecmp($value,'ASC')==0 || strcasecmp($value,'DESC')==0) My humble suggestion,

Alejandro

catfan commented 6 years ago

You can still discuss it on the closed issue or reopen it.

For the whole Medoo API design, the SQL keywords like LIMIT, GROUP, AND, OR and more, are required uppercase that will be easier to discover they are the SQL keywords from other PHP data while the first look at the code. If all of them are lowercase, it is hard to know it is a keyword or a data.

$database->select("account", "user_id", [
    "ORDER" => [
        "profile_id" => "DESC",
        "date" => "ASC"
    ]
]);

$database->select("account", "user_id", [
    "order" => [
        "profile_id" => "desc",
        "date" => "asc",
        "age" => "acs"
    ]
]);
lamuzzachiodi commented 6 years ago

> Hard to know it is a keyword or a data It sounds like Medoo could confuse keywords with data or vicecersa if i use the incorrect sensitivity. It's possible?. I don´t think so. > Will be easier to discover ... SQL keywords... May be, but the convertion should not be so complicated : for example to use _"array_change_keycase" for change all a complete array (i.e "WHERE").

Even PHP it's partially sensitive. Because that you could write 'select' in your example above. ;-)