Welcome Guest, Not a member yet? Register   Sign In
Events::on('DBQuery')
#1

Hi 

When the system executes a query I want to parse the query and modify it. I want to create a BeforeExecuteQuery method or event. 

An example: 
The users => ID, Name, Password table 


PHP Code:
$users = new \ App\Models\UserModel(); 
$res 
= $ users->findAll (); 
// select ID, Name, Password from users 


I want the Password field to always be removed from query

For now it's catching the query like this, but I can't change it
Events::on('DBQuery', 'My_parser_query');
Reply
#2

The ideal would be to create a new function in the model with the db fields as parameters. Or I would add a select before findAll with only the fields I want to display. There is no need for an event for this.
Reply
#3

Modify all methods present and all future ones - to delete one field ??? One event that makes sure that such a field is not returned in any method is better
Reply




Theme © iAndrew 2016 - Forum software by © MyBB