If we are using php mysqli or PDO wrapper class, do they prevent SQL injection risks ?
E.g.
https://github.com/ezSQL/ezSQL
or
https://github.com/bennettstone/simple-mysqli
Always Use prepared statements and parameterized queries is advised by all experts.
wrapper class is useful for less coding in quick time and also help to reduce repeated coding.
Then how can we use wrapper class along with prepared statements and parameterized queries simultaneously ?
I am confused by this?
e.g.
example from - How can I prevent SQL injection in PHP?
Use prepared statements and parameterized queries
$stmt = $dbConnection->prepare('SELECT * FROM employees WHERE name = ?');
$stmt->bind_param('s', $name);
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
// do something with $row
}
And with wrapper class, e.g. we use it as
$name = $database->filter($_POST['name']);
$query = $database->get_results("select* from employee where name='$name'");
foreach ($query as $row){
// do something with $row
}
Then where to use wrapper and where to use prepared statements ?
how to use both simultaneously ?
How to achieve sql injection prevention while using wrapper class ?
mysqli_
orPDO
– RiggsFolly