Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do to no sort by the first col by default when no specify order in the url ? #1047

Open
mapoub opened this issue Nov 11, 2024 · 1 comment
Assignees

Comments

@mapoub
Copy link
Contributor

mapoub commented Nov 11, 2024

hello @mevdschee

When i call php-crud-api "http://XXXXXXXXXX/records/test", i constate that php-crud-api sort data by the first col.
I don't want sort.
How do to no sort by the first col by default ?
if this already exist, it"s possible to add in the readme ?

Example :
1/ I have for example a table "test" with this data :
val ( is the col)
3
1
2

2/ "select * from test" in mysql
result is
val
3
1
2

3/ call php-crud-api -> http://XXXXXXXXXX/records/test
result is
{
"records": [
{"val": 1},
{"val": 2},
{"val": 3}]
}
Datas are sorted !!!!

How do to no sort by the first col by default . I would like to have this :
{"records": [
{"val": 3},
{"val": 1},
{"val": 2}]}

Thx for your answer ;-)

@mevdschee
Copy link
Owner

mevdschee commented Nov 22, 2024

Technically records in a database have no order (I know, I know...).

See: https://dba.stackexchange.com/questions/186885/is-there-a-default-select-order

You can sort using the "order=" GET parameter:

https://github.com/mevdschee/php-crud-api?tab=readme-ov-file#ordering

GET /records/test?order=val,desc

Does that help?

@mevdschee mevdschee self-assigned this Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants