Add "global" where clause to any SQL-Query |
[eluser]Unknown[/eluser]
Hi there! Does anyone know if it's possible to add a Where-Clause which will be added to any SQL-Query automatically? For example: I want to make sure my users select/update/delete only their DB-data. So for Security I added to all my SQL-Querys: $this->db->where('owner', $user_id); For simplicity and I don't forget to add this where-clause somewhere, is it possible to setup somehow a "globally" valid where-statement, which is added to any sql-query by default? This doesn't need to be application-wide, but at least Model-wide Thanks for any hints!
[eluser]mddd[/eluser]
Check out Active Record caching. It allows you to store pieces of queries just like your 'where owner=$user_id' piece.
[eluser]Unknown[/eluser]
great thanks a lot! actually this does exactly what I asked for ... but after testing it, I see that I can't actually work this way ;-) as this where-clause is now added to ALL queries (yeah, i know I asked for it ![]() any other idea I can add this now not "globally" but only Model-wide, so it is only effect my Model-Queries? |
Welcome Guest, Not a member yet? Register Sign In |