This is a awkward issue, and I'm running out of alternatives to workaround.
I have a server running Wamp 3.0.6, with PHP 5.6. My code must connect in a MySQL (local) and a PostgreSQL (remote server).
Everything is working fine, and seemingly out of nowhere it stops returning data from PG. After few seconds or minutes, it just works again.
Even when I'm not able to get data from PG, phpPgAdmin keeps working.
Here is my connection function:
function pdo_pgsql($sql){
$host = '000.000.000.000';
$user = 'user';
$pass = 'pass';
$db = 'db';
try {
$PDO = new PDO( 'pgsql:host=' . $host . ';dbname=' . $db . ';port=5432', $user, $pass, array(
PDO::ATTR_PERSISTENT => true
));
}
catch ( PDOException $e ) {
echo 'Error: ' . $e->getMessage(); exit;
}
$result = $PDO->query( $sql );
if (is_array($result)){
$row = $result->fetchAll( PDO::FETCH_ASSOC );
}else{
$row = $result;
}
return $row;
}
Any suggestion to help me with this?
Thanks