If you decide to deallocate (unprepare) a previously prepared sql command it might be better to quote the sql name as in
DEALLOCATE "theNameOfMySQL"
instead of (the more natural)
DEALLOCATE theNameOfMySQL
PostgerSQL preserves the case of your identifiers if, and only if, you quote them. The pg_prepare function preserves the case of the sql name you use.
A complete example would be
$sql = 'SELECT * FROM user WHERE cod_user = $1';
$sqlName = 'selectUserByCode';
if (!pg_prepare ($sqlName, $sql)) {
die("Can't prepare '$sql': " . pg_last_error());
}
$rs = pg_execute($sqlName, array(1));
do whatever you want with $rs and finally
$sql = sprintf(
'DEALLOCATE "%s"',
pg_escape_string($sqlName)
);
if(!pg_query($sql)) {
die("Can't query '$sql': " . pg_last_error());
}