![]() |
Re: IF NOT EXIST abfrage mit MySQL
Sicher, dass das geht? Ansonsten nochmal
![]() |
Re: IF NOT EXIST abfrage mit MySQL
Hmm... Das konnte mir leider auch nicht helfen.
|
Re: IF NOT EXIST abfrage mit MySQL
Dann kann ich Dir leider auch nicht helfen, weil ich anscheinend nicht verstehe, was Du vorhast.
|
Re: IF NOT EXIST abfrage mit MySQL
Ich möchte das dieser code ausgeführt wird:
SQL-Code:
Falls $botname nicht existiert. $Botname ist die variable in der config wo man auswählen muss welchen spieler er steuert
INSERT INTO ´username´ = $botname `users` (`id`,
`username`, `password`, `banned`, `villages`, `points`, `ennobled_by`, `ally`, `ally_titel`, `ally_found`, `ally_lead`, `ally_invite`, `ally_diplomacy`, `ally_mass_mail`, `rang`, `villages_mode`, `attacks`, `new_report`, `new_mail`, `market_sell`, `market_buy`, `market_ratio_max`, `killed_units_att`, `killed_units_att_rank`, `killed_units_def`, `killed_units_def_rank`, `killed_units_altogether`, `killed_units_altogether_rank`, `do_action`, `last_activity`, `birthday`, `vacation_id`, `vacation_name`, `vacation_accept`, `b_day`, `b_month`, `b_year`, `sex`, `home`, `image`, `personal_text`, `window_width`, `show_toolbar`, `dyn_menu`, `confirm_queue`, `map_size`, `memo`, `map_reload`, `graphical_overwiev`, `overview`, `stufen`, `winter`) VALUES (NULL, '$botname', 'e10adc3949ba59abbe56e057f20f883e', 'N', '', '', '', '-1', '', '0', '0', '0', '0', '0', '', 'prod', '0', '0', '0', 'all', 'all', '3', '', '', '', '', '', '', '', '', '', '-1', '', '0', '', '', '', 'x', '', '', '', '840', '1', '1', '1', '9', '', '', '1', 'new', 'yes', '');'1', '1', '1', '9', '', '', '1', 'new', 'yes', ''); |
Re: IF NOT EXIST abfrage mit MySQL
Das Einfachste wäre doch, das in 2 Schritten zu machen. Zuerst nachschauen, ob es den User bereits gibt:
SQL-Code:
Kommt da eine 0 zurück (kein Datensatz vorhanden), dann mit INSERT einfügen
SELECT COUNT(*) AS Anzahl
FROM Tabelle WHERE username = $botname
SQL-Code:
ansonsten Datensatz updaten
INSERT INTO Tabelle(Feldliste) VALUES(Wertliste)
SQL-Code:
UPDATE Tabelle
SET Feld1 = Wert1, Feld2 = Wert2,... WHERE username = $botname |
Re: IF NOT EXIST abfrage mit MySQL
Wie soll ich das denn abfragen ob 0 kommt?
$usernotexists = <<<MEHRZEILEN mysql_query("SELECT COUNT(*) AS Anzahl FROM Tabelle WHERE username = $botname") MEHRZEILEN; if ($usernotexists == 0) { mysql_query("INSERT INTO Tabelle(Feldliste) VALUES(Wertliste)"); } Und noch eine Frage: mysql_query("SELECT COUNT(*) AS Welche anzahl? FROM Tabelle WHERE username = $botname") |
Re: IF NOT EXIST abfrage mit MySQL
Mit der Abfrage bekommst Du eine Datenmenge mit genau einem Datensatz zurück. Dieser Datensatz enthält das Feld "Anzahl", in dem die Anzahl der User mit diesem Namen drinsteht. Und wie man das in PHP abfragt, kannst Du
![]() |
Re: IF NOT EXIST abfrage mit MySQL
Könntest du mir eine PN schicken und mir das erklären?
|
Re: IF NOT EXIST abfrage mit MySQL
Kann ich, aber erst ab 16:00 Uhr.
|
Re: IF NOT EXIST abfrage mit MySQL
Ok ich werde da sein :D xD
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:00 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz