
äh ich hab grad eine Frage zum UNIQUE...
Und zwar füre ich folgende MySQL Operation durch:
Code: Alles auswählen
$sql = "INSERT INTO " . BUDDIES_TABLE . " (user_id, buddy_id, active)
VALUES ($user_id, $buddy_id_, '1')";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not add the user to your buddylist', '', __LINE__, __FILE__, $sql);
}
$sql = "UPDATE buddies
SET active = 1
WHERE user_id = '$buddy_id_' AND buddy_id = '$user_id'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update update buddys table', '', __LINE__, __FILE__, $sql);
}
$sql = "UPDATE users
SET buddy_alert = buddy_alert - 1
WHERE user_id = '$user_id'";
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Could not update buddy alert table', '', __LINE__, __FILE__, $sql);
}
Nun meine Frage, sieht jemand grad einen Fehler?
Oder kann ich rgendwie UNIQUE auf zwei werte setzen?
Dass z.B user_id 2 in Verbindung mit buddy_id 4 nur einmal vorhanden sein darf?