[ nenadovic85 @ 26.01.2021. 13:35 ] @
Koristim pdo

ali nisam siguran da li se vrsi sanacija. Upit mi izgleda ovako prakticno:

Code:

$link = new DB();
$query = "INSERT INTO users (id, name, email) VALUES (?, ?, ?)";
$result = $link->InsertRow($query, [$id, $name, $email]);

if ($result) {
 //
}


Da li tu nešto treba dodati. Ovo je samo primer...

Ovako mi izgleda funkcija 'InsertRow'
Code:

    public function InsertRow($query, $params = []) {
        try {
            $stmt = $this->link->prepare($query);
            $stmt->execute($params);
            return $stmt->rowCount();
        }
        catch (PDOException $ex) {
            throw new Exception($ex->getMessage());
        }
    }
[ Tpojka @ 26.01.2021. 14:10 ] @
Pogledaj šta ircmaxell kaže na tu temu (temu SQL injection-a):

Are PDO prepared statements sufficient to prevent SQL injection?

SQL injection that gets around mysql_real_escape_string()