Would it be possible to have a where clause on setRelationship?
Thanks
⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠
Posted 17 April 2017 - 17:45 PM
Would it be possible to have a where clause on setRelationship?
Thanks
Posted 18 April 2017 - 11:02 AM
yes, you can.
you need to use this syntax :
$crud->setRelation('customer_id','customers','{lastname} {firstname}',['customers.city = ?' => '%Toronto%']);
you can use = , > , < or even LIKE statement. Check this other example:
$crud->setRelation('customer_id','customers','{lastname} {firstname}',['customers.city LIKE ?' => '%New%']);
The first example show lastname and firstname instead of the customer_id field. Only the customers in the city of Toronto shows up.
The second example is similar but you accept every customer with the word "New" in the city field. Example: New York, New Orleans.....
Hope this examples help you understand. Bye
Posted 10 July 2017 - 04:15 AM
I think @darkstalker covered my answer :)
One more thing to have in mind is that unlike the community edition, Grocery CRUD Enterprise is coming with extra where parameters for security. So for example in case you are having only the setRelation with where then the user can't see any other entries even if the user will try to hack it!
If you guys need more documentation about the extra security implementations of GCE let me know.
Thanks
Johnny