Problem with connection to postgres database in php

1

I am making a connection with postgres database but there is an error that I can not determine, following the codes:

Config.php :

define('DB','sistema_postgres');
define('HOST','localhost');
define('USER','postgres');
define('PASS','123');

Database.php :

require_once 'config.php';
class Database {
   private $db;
   private $host;
   private $user;
   private $pass;
   private $conn;

   public function __construct(){
     $this->host = HOST;
     $this->db = DB;
     $this->user = USER;
     $this->pass = PASS;
     $this->conn = new PDO("pgsql:host={$this->host};port=5432;dbname={$this->db};user={$this->user};password={$this->pass}");
   }

   protected function getConn(){
     return $this->conn;
   }
}

TurmaDao.php

require_once('database.php');
class TurmaDAO extends Database implements IDAO{
    private $turma;
    private $db;

    public function __construct($turma=null) {
        if(isset($turma)){
            $this->setTurma($turma);
        }
        parent::__construct();
        $this->db = parent::getConn();
    }

    public function listAll() {
        $stmt = $this->db->prepare('SELECT * FROM turma');
        $stmt->execute();
        try{
            $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
        }
        catch(PDOException $e){
            echo $e->getMessage();
            die();
        }
        return $rs;
    } 
}

turma.php

require_once 'TurmaDAO.php';
$t = new TurmaDAO();
$rs = $t->listAll();
var_dump($rs);

The following error message is being returned:

  

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE [08006] [7] FATAL: password authentication failed for user   "SYSTEM" '

Anyway, this is an error with the connection data, the strange thing is that the database user defined in my application is 'postgres' and something is changing the user to 'SYSTEM'

What might be causing this error?

    
asked by anonymous 24.03.2016 / 15:04

0 answers