php-crud-api icon indicating copy to clipboard operation
php-crud-api copied to clipboard

Order on column of included table

Open SirTrollsalot opened this issue 7 years ago • 9 comments

Is it possible to order a List by an includet Column?

for example: api.php/tbl_contacts?columns=contact_id,Name,EMail,tbl_contacttype.Description&include=tbl_contacttype&order=tbl_contacttype.Description&page=1,30

SirTrollsalot avatar Jan 18 '18 10:01 SirTrollsalot

Hi, thank you for reaching out. That is not possible, but you may list the included table and include the original table and then list by the included column. I hope that helps.

Alternatively you can do client side sorting (using your own JavaScript implementation).

mevdschee avatar Jan 18 '18 10:01 mevdschee

Then i guess i also can't filter on those columns, client side sorting and filtering is not an option, because if i use pages i can only filter one page.

Thanks for the help tho, will try your first suggestion

SirTrollsalot avatar Jan 18 '18 10:01 SirTrollsalot

Yes or you can do two request, where you retrieve id's in the first and then do an "in" filter in the second. You need to combine those two results (manually) in JavaScript. Good luck!

mevdschee avatar Jan 18 '18 10:01 mevdschee

I'll keep this open as a feature request.

mevdschee avatar Jan 18 '18 10:01 mevdschee

Hey it's me.... again...i'm sorry... Is there any way i can combine All and Any in the Filter? so logically: Filter[]=id,cs,1 AND (Filter[]=name,cs,text OR Filter[]=adress,cs,text)

I do not want to download it and combine it manually, because i am using pages. Downloading everything would also be bad because of performance reasons

Edit: I want to Apply the one Filter on a Column that is also on an includet table. i tried using adding the table to the attribute and using different satisfy like said in your description but this did not work:

table: api.php/tbl_contacts? columns: columns=contact_id,Name,EMail,tbl_contacttype.ID_contacttype,tbl_contacttype.Description filter: &filter[]=tbl_contacttype.ID,eq,1&filter[]=Name,cs,text&filter[]=EMail,cs,text include: &include=tbl_contacttype order: &order=Name page: &page=1,30 satisfy: &satisfy=tbl_contacttype.all,tbl_contact.any

Edit 2.0: I found out that it works if i add the table to every attribute. Now it filters every table like it should, the only Problem is that every contact is shown, and only the one with the filtert contact type have the attribute. But i can work with that by just filtering out the one that does not have a contacttype.

Sorry for wasting your time and thanks for the help yesterday again.

SirTrollsalot avatar Jan 19 '18 07:01 SirTrollsalot

Hey it's me.... again...i'm sorry...

Sure.. no problem. Although different issues would be better in different tickets :-).

Is there any way i can combine All and Any in the Filter?

This currently not supported as there is no nesting syntax.

Sorry for wasting your time and thanks for the help yesterday again.

Don't be. I'm glad you got it working. Enjoy the software!

mevdschee avatar Jan 19 '18 08:01 mevdschee

You asked:

Is there any way i can combine All and Any in the Filter?

I answered:

This currently not supported as there is no nesting syntax.

But this is no longer true (in v2), see:

https://github.com/mevdschee/php-crud-api#multiple-filters

You can now combine AND and OR :-)

Enjoy!

mevdschee avatar Mar 24 '19 22:03 mevdschee

There are no plans to support sorting on fields of included tables.

mevdschee avatar Mar 24 '19 22:03 mevdschee

I'll keep this open as a feature request.

mevdschee avatar Mar 24 '19 22:03 mevdschee