[Résolu] moderation SQL
#8
Oui pour l'ordre je l'utilise souvent.
Mais la dans l'exemple sa faisait dans le désordre en mettant un "order by cmd", chose que je ne comprenez pas pourquoi.

Exemple dans ce code TCL j'ai utilisé le "order by mots", ce qui donne l'ordre du champ (mots) à chercher.

Et si je comprend bien le système je regarde la colonne "mots" dans la base SQL, si j'ai un retour donc je n'exécute rien.
Si j'ai aucun retour, alors ont enregistre.

Voici l'exemple :

tcl
bind pub o|o .+badword +badword
proc +badword { nick host hand chan arg } {
	set colonne(mots) [string tolower [lindex $arg 0]]
	set colonne(salon) [lindex $arg 1]
	if ![onchan $nick $::back(chan)] {
		putserv "notice $nick :\00314Erreur vous devez être sur\003 \0034$::back(chan)\0034"
		return
	}
	if {$colonne(mots)==""} {
		putserv "notice $nick :\00314Incorrect veuillez mettre un mot\003. Exemple : .+badword \0034connard #salon\0034"
		return 0
	}
	if {![string match #* $colonne(salon)]} {
		putserv "notice $nick :\00314Incorrect veuillez mettre un salon\003. Exemple : \0034#SQL\0034"
		return 0
	}
	service:connect
	mysqlsel $::mysqlink "SELECT * FROM `badword` ORDER BY mots"
	if {[mysqlresult $::mysqlink rows] ne 0} {
		while {[set row [mysqlnext $::mysqlink]] != ""} {
			set checkmots [lindex $row 0]
			if {[string match [string tolower $colonne(mots)] [string tolower $checkmots]]} {
				putserv "notice $nick :\00314Mot invalide ! le mot\003 (\0034$colonne(mots)\0031) et déjà enregistré !"
				return 0
			}
		}
		service:deconnect
	}
	service:connect
	mysqlsel $::mysqlink "INSERT INTO badword (mots, salon) VALUES ('$colonne(mots)', '$colonne(salon)')"
	service:deconnect
	puthelp "privmsg $::back(chan) :$::chanlog(+badword) \00314Sur\003 \0034$chan\0034 \0031\002$hand@$nick\002\0031 (\0037$colonne(mots)\0031)"
}



Bien évidament, j'utilise le "order by mots", uniquement pour ma recherche si "mots" et existant.
Sinon je "insert into" le mot

Je ne c'est pas si je m'exprime bien, et si c'est ce que tu veut me faire comprendre
Vous interdisez les erreurs, vous empêchez ainsi la victoire.

Ma super kikoo-page loll
Répondre Avertir


Messages dans ce sujet
moderation SQL - par aliasangelius - 07/03/2017, 12:51
RE: moderation SQL - par CrazyCat - 07/03/2017, 13:59
RE: moderation SQL - par aliasangelius - 07/03/2017, 14:08
RE: moderation SQL - par aliasangelius - 07/03/2017, 17:57
RE: moderation SQL - par CrazyCat - 08/03/2017, 00:53
RE: moderation SQL - par aliasangelius - 08/03/2017, 14:42
RE: moderation SQL - par CrazyCat - 08/03/2017, 16:47
RE: moderation SQL - par aliasangelius - 08/03/2017, 17:42
RE: moderation SQL - par CrazyCat - 08/03/2017, 18:37
RE: moderation SQL - par aliasangelius - 08/03/2017, 19:24
RE: moderation SQL - par CrazyCat - 09/03/2017, 01:06
RE: moderation SQL - par aliasangelius - 09/03/2017, 01:27
RE: moderation SQL - par CrazyCat - 09/03/2017, 13:00
RE: moderation SQL - par aliasangelius - 09/03/2017, 15:45
RE: moderation SQL - par CrazyCat - 10/03/2017, 00:48
RE: moderation SQL - par aliasangelius - 10/03/2017, 14:43

Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté