1

In a EE plugin if I construct a sql statement based on passed in parameters and use a EE->db->query($sql) call does the query function prevent SQL Injections or do I need to change my code to use some other query function to bind parameters?

1

You should always scrub any user input before it gets to your query.

The first thing you should do is run and input variables through the input class. i. e. $var = ee()->input->post('my_var', TRUE) this will run the XSS filter on the data.

Then when you use it in your sql: (this used to be a thing, but I can't find in the EE3 docs, they may of rolled it into the query or get function)

$var =ee()->db->escape_str($var)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.