catfan / Medoo

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

Feature Request : Global filter for tenancy or saas cases etc. #986

Open mehmetriza opened 3 years ago

mehmetriza commented 3 years ago

I simply need to add where into all queries. Exceptionally insert queries doesn't have where but it contains the exactly same column(s) as row field(s). Actually i know i can do that with extending Medoo class but i guess if it's possible in main repo, better than that.

For example:

$db->addGlobalWhere('tenancy',["tenant_id"=>$tenant_id]);

$db->select("customers","*",["type"=>"sellers"]);
// It would be run like below
$db->select("customers","*",["type"=>"sellers","tenant_id"=>$tenant_id]);
// For disabling
$db->disableGlobalWhere('tenancy');

Thanks for all your efforts.

catfan commented 3 years ago

I don't think this is really needed for the database framework.

You can maintain the where alone (global / middleware) for the best flexibility.