Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.20 KB | None | 0 0
  1. proc insertSQL { table donnees {options ""} } {
  2.  
  3.         variable sql
  4.         # Connexion à la base de données
  5.         connexion
  6.        
  7.         set n 0
  8.         # On récupère le nom des champs de $table
  9.         set nameChamps [::mysql::col $sql(n_link) $table name]
  10.         set nbChamps [llength $nameChamps]
  11.         # on créer un tableau , on y donne le nom des champs    
  12.         foreach champs $nameChamps {
  13.             set colone($n) $champs
  14.             incr n
  15.         }  
  16.         set index 0  
  17.                  
  18.         if { [llength $donnees] eq [expr $nbChamps-1] } {
  19.             set baseReq "::mysql::sel $sql(n_link) \"INSERT INTO $table SET\""
  20.             for { set i 1 } { $i < [expr $nbChamps] } { incr i } {
  21.                 lappend baseReq "$colone($i) = '[::mysql::escape [lindex $donnees $index]]',"
  22.                 puts "$baseReq"
  23.                 incr index
  24.             }
  25.         } else {
  26.             puts "Error: Nombre de champs non correspondant"
  27.         }
  28.         deconnexion
  29.         #return $baseReq
  30.     }
  31.  
  32. J'obtiens ceci : ::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