Hi
I am trying to connection my database ODBC using function.
I am getting an error Connection error: could not find driver
mycode is
<?php
class Database{
// specify your own database credentials
private $host = "servername";
private $db_name = "databsename.schemaname";
private $username = "username";
private $password = "password";
public $conn;
// get the database connection
public function getConnection(){
$this->conn = null;
try{
$this->conn = new PDO("odbc:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
}catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
}
?>
Please help me to fix the issue.