Below I have a code snippet adapted to exemplify this question:
<?php
$params = [
':codUser' => $_SESSION['data-user']['codigo'],
':codCarrinho' => $codCarrinho,
':codPremio' => $codPremio,
':quantidade' => $quantidade,
':subtotal' => $subtotal
];
$query = 'Call addItemCarrinho(:codUser, :codCarrinho, :codPremio, :quantidade, :subtotal)';
$preparedQuery = self::getConn()->prepare($query);
foreach ($params as $key => $value) {
$preparedQuery->bindValue($key, $value);
}
$preparedQuery->execute();
$result = $preparedQuery->fetchAll(PDO::FETCH_OBJ);
?>
This is the form I currently use. But I've been researching and reading some articles that say it's not necessary to use prepare
in Procedures. But for fear I continue to use. My question is if it is possible to use SQL injection
in precedures?