Someone can say me if this is the better way to know the error code of one query? I read it can do with pg_send_query and then read with pg_get_result but sometimes it doesn't works me. And trying and reading I wrote the PHP code below, but I belive it's a horrible code. It's possible do the same with pg_query instruction? And if it's the only way, this is the good solution? And how many iterations it's good?
PHP Code:
$send_query= @pg_send_query($connection,$SQL);
if ($send_query){
$i=0;
do
{
$i++;
$this->result = @pg_get_result($connection);
}while ($i < MAX_ITERATIONS && $this->result === FALSE );
if ($this->result === FALSE){
return (FALSE);
}
if (pg_result_status($this->result) === PGSQL_FATAL_ERROR)
{
// Error case...
$error_code = @pg_result_error($this->result);
}
}
Thanks in advance, Jordi