Probleme mit meinem Versuch, ein UPSERT @ zu implementier

Ich habe dieses Problem, wenn ich eine Bedingung überprüfe, um eine Tabelle in PostgreSQL zu aktualisieren. Es muss überprüft werden, ob der Benutzer dies einmal heruntergeladen hat, und wenn ja, +1 in @ hinzufügeacessos.

<?php
$result2 = pg_query("SELECT * from downloads WHERE (nome = $_POST[nome_download] AND email = $_POST[email_download])");
if (pg_num_rows($result2) == 0){
$result = pg_query("INSERT INTO downloads (nome, email, estado, arquivo, acessos) VALUES ('$_POST[nome_download]','$_POST[email_download]','$_POST[estado_download]','$_SESSION[nome_arquivo_download]','1')");
}else{
$arr[acessos] = $arr[acessos] + 1;
$result = pg_query("UPDATE downloads SET acessos = $arr[acessos] WHERE (nome = $_POST[nome_download] AND email = $_POST[email_download])");
}


if (!$result){
echo "Não foi possível realizar o cadastro. Tente fazer o download mais tarde.";
}
else
{
echo "soft_bd";
pg_close();
}
?>

Antworten auf die Frage(2)

Ihre Antwort auf die Frage