Fra le due implementazioni quale risulta più sicura:
Opzione 1
Codice: Seleziona tutto
public function select($sql, $array = array(), $fetchMode = PDO::FETCH_ASSOC) {
$sth = $this->prepare($sql);
foreach ($array as $key => $value) {
$sth->bindValue($key, $value);
}
$sth->execute() or die(print_r($sth->errorInfo(),true));
return $sth->fetchAll($fetchMode);
}
//CHIAMATA
$result = $this->db->select('SELECT "utName" FROM base.utenti WHERE "utUsername" = :utUsername', array(':utUsername' => Session::get('user')));
Codice: Seleziona tutto
public function select2($sql, $array = array(), $fetchMode = PDO::FETCH_ASSOC) {
$sth = $this->prepare($sql);
$sth->execute($array) or die(print_r($sth->errorInfo(),true));
return $sth->fetchAll($fetchMode);
}
//CHIAMATA
$result = $this->db->select2('SELECT * FROM base.utenti WHERE "utUsername" = ?', array(Session::get('user')));