Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- proc insertSQL { table donnees {options ""} } {
- variable sql
- # Connexion à la base de données
- connexion
- set n 0
- # On récupère le nom des champs de $table
- set nameChamps [::mysql::col $sql(n_link) $table name]
- set nbChamps [llength $nameChamps]
- # on créer un tableau , on y donne le nom des champs
- foreach champs $nameChamps {
- set colone($n) $champs
- incr n
- }
- set index 0
- if { [llength $donnees] eq [expr $nbChamps-1] } {
- set baseReq "::mysql::sel $sql(n_link) \"INSERT INTO $table SET\""
- for { set i 1 } { $i < [expr $nbChamps] } { incr i } {
- lappend baseReq "$colone($i) = '[::mysql::escape [lindex $donnees $index]]',"
- puts "$baseReq"
- incr index
- }
- } else {
- puts "Error: Nombre de champs non correspondant"
- }
- deconnexion
- #return $baseReq
- }
- ::mysql::sel mysql37 {INSERT INTO botonchan SET} {botnick = 'Angellus',} {bothost = '*!*@173576584.fr',} {botversion = ' eggdrop v1.6.20 ',}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement