I would want to check if there is a connexion with the database before execute the query . But if i write the if mysql_connection ... it passes twice on mysql_connection.
def mysql_connection puts "mysql_connection 1"
read_config_file
@connexion = Mysql2::Client.new(:host => @conf['host'], :username => @conf['user'], :password => @conf['password'], :database=> @conf['base'], :port => @conf['port'])
end
######################
# #
# USER QUERY MYSQL #
######################
def mysql_select_user(value)
puts "select"
# if mysql_connection then
p = mysql_connection.query("select #{value} from User")
p.each do |f|
puts "value : #{f}"
mysql_close
end
# else
# end
end
Aucun commentaire:
Enregistrer un commentaire