I want to make a simple connection to the database but every time I test it, after a long loading of the page it generates a Warning.
File bank.class.php:
<?php
abstract class banco
{
public $servidor = "localhost";
public $usuario = "postgres";
public $porta = 80;
public $senha = "senha5";
public $nomebanco = "wmma";
public $conexao = NULL;
public $dataset = NULL;
public $linhasafetadas = -1;
public function __construct()
{
$this->conecta();
}
public function __destruct()
{
if($this->conexao != NULL){
pg_close($this->conexao);
}
}
public function conecta()
{
$this->conexao = pg_connect($this->servidor, $this->porta, $this->nomebanco, $this->usuario, $this->senha);
echo "Método Conecta foi chamado corretamente" . $this->conexao;
}
Test.class.php file:
<?php
require_once("banco.class.php");
class teste extends banco
{
}
Test.php file:
require_once("classes/teste.class.php");
$testando = new teste();
As a result I have the following:
Warning: pg_connect (): Unable to connect to PostgreSQL server: server closed the connection unexpectedly This probaly means the server terminated abnormally before or while processing the request. in ... bank.class.php on line 37
I have already restarted apache and postgres, I thought it could be an insistence on the connection, but it did not solve.