这是我的连接类。
class Database {
private $host;
private $port;
private $dbname;
private $username;
private $password;
function __construct($host, $port, $dbname, $username, $password) {
$this->host = $host;
$this->port = $port;
$this->dbname = $dbname;
$this->username = $username;
$this->password = $password;
try {
$conn = new PDO("pgsql:host=$this->host port=$this->port dbname=$this->dbname", "$this->username", "$this->password");
echo "PDO connection object created";
}
catch(PDOException $e) {
echo $e->getMessage();
}
}
}
$db = new Database('host','5432','eu','eu','eu');
你能帮我做正确的 QUERY 类,这样可以避免 sql 注入吗?
谢谢!