Welcome Guest, Not a member yet? Register   Sign In
Enforce the Where parameter for Query Builder
#1

When using the update and delete methods with Builder, how do I ensure that the operation fails if where is not specified? Which files do we need to check?
Reply
#2

(This post was last modified: 04-04-2024, 05:22 PM by ozornick.)

Check the builder's result to see if it is true or false (or null).. Do you need it?
Simple CI 4 project for beginners codeigniter-expenses
Reply
#3

$builder->getCompiledQBWhere()
Reply
#4

(This post was last modified: 04-04-2024, 08:54 PM by mywebmanavgat.)

When the Where condition is not specified, we do not want to take this risk because the entire table will be updated or deleted. So we don't want a query without a where condition to go to the database.

If there is no where in the update and delete arguments when creating or creating the active records tsql code, instead of sending the tsql code to sqle, stop the script and suppress the error.

Translated with DeepL

(04-04-2024, 08:53 PM)mywebmanavgat Wrote: When the Where condition is not specified, we do not want to take this risk because the entire table will be updated or deleted. So we don't want a query without a where condition to go to the database.

If there is no where in the update and delete arguments when creating or creating the active records tsql code, instead of sending the tsql code to sqle, stop the script and suppress the error.

Which kernel files should we focus on for this.
Reply
#5

maybe try event beforeDelete, beforeUpdate?
Simple CI 4 project for beginners codeigniter-expenses
Reply




Theme © iAndrew 2016 - Forum software by © MyBB