anchor.diff:  	set category = "Special Verbs"
   	if(!check_rights(R_PERMISSIONS))
   		return
  -	if(!SSdbcore.IsConnected())
  +	if(!SSdbcore.Connected())
   		to_chat(src, "<span class='danger'>Failed to establish database connection.</span>")
   		return
  -	var/returned = create_poll_function()
  -	if(returned)
  -		var/datum/DBQuery/query_check_option = SSdbcore.NewQuery("SELECT id FROM [format_table_name("poll_option")] WHERE pollid = [returned]")
  -		if(!query_check_option.warn_execute())
  -			return
  -		if(query_check_option.NextRow())
  -			var/datum/DBQuery/query_log_get = SSdbcore.NewQuery("SELECT polltype, question, adminonly FROM [format_table_name("poll_question")] WHERE id = [returned]")
  -			if(!query_log_get.warn_execute())
  -				return
  -			if(query_log_get.NextRow())
  -				var/polltype = query_log_get.item[1]
  -				var/question = query_log_get.item[2]
  -				var/adminonly = text2num(query_log_get.item[3])
  -				log_admin("[key_name(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"] - Question: [question]")
  -				message_admins("[key_name_admin(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"]<br>Question: [question]")
  -		else
  -			to_chat(src, "Poll question created without any options, poll will be deleted.")
  -			var/datum/DBQuery/query_del_poll = SSdbcore.NewQuery("DELETE FROM [format_table_name("poll_question")] WHERE id = [returned]")
  -			if(!query_del_poll.warn_execute())
  -				return
  -
  -/client/proc/create_poll_function()
   	var/polltype = input("Choose poll type.","Poll Type") in list("Single Option","Text Reply","Rating","Multiple Choice", "Instant Runoff Voting")|null
   	var/choice_amount = 0
   	switch(polltype)
  
positive.code: 	if(!question)
  		return
  	question = sanitizeSQL(question)
  	var/datum/DBQuery/query_polladd_question = SSdbcore.NewQuery("INSERT INTO [format_table_name("poll_question")] (polltype, starttime, endtime, question, adminonly, multiplechoiceoptions, createdby_ckey, createdby_ip, dontshow) VALUES ('[polltype]', '[starttime]', '[endtime]', '[question]', '[adminonly]', '[choice_amount]', '[sql_ckey]', INET_ATON('[address]'), '[dontshow]')")
  	if(!query_polladd_question.warn_execute())
  		return
  	if(polltype == POLLTYPE_TEXT)
  		log_admin("[key_name(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"] - Question: [question]")
  		message_admins("[key_name_admin(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"]<br>Question: [question]")
  		return
  	var/pollid = 0
  	var/datum/DBQuery/query_get_id = SSdbcore.NewQuery("SELECT id FROM [format_table_name("poll_question")] WHERE question = '[question]' AND starttime = '[starttime]' AND endtime = '[endtime]' AND createdby_ckey = '[sql_ckey]' AND createdby_ip = INET_ATON('[address]')")
  	if(!query_get_id.warn_execute())
  		return
  	if(query_get_id.NextRow())
  		pollid = query_get_id.item[1]
  	var/add_option = 1
  	while(add_option)
  		var/option = input("Write your option","Option") as message|null
  		if(!option)
  			return pollid
  		option = sanitizeSQL(option)
  		var/percentagecalc = 1
  		if (polltype != POLLTYPE_IRV)
  			switch(alert("Calculate option results as percentage?",,"Yes","No","Cancel"))
  				if("Yes")
  					percentagecalc = 1
  				if("No")
  					percentagecalc = 0
  				else
  					return pollid
  		var/minval = 0
  		var/maxval = 0
  		var/descmin = ""
  
negative.code: 				add_option = 0
  			else
  				return 0
  	var/datum/DBQuery/query_polladd_question = SSdbcore.NewQuery("INSERT INTO [format_table_name("poll_question")] (polltype, starttime, endtime, question, adminonly, multiplechoiceoptions, createdby_ckey, createdby_ip, dontshow) VALUES ('[polltype]', '[starttime]', '[endtime]', '[question]', '[adminonly]', '[choice_amount]', '[sql_ckey]', INET_ATON('[address]'), '[dontshow]')")
  	if(!query_polladd_question.warn_execute())
  		return
  	if(polltype != POLLTYPE_TEXT)
  		var/pollid = 0
  		var/datum/DBQuery/query_get_id = SSdbcore.NewQuery("SELECT LAST_INSERT_ID()")
  		if(!query_get_id.warn_execute())
  			return
  		if(query_get_id.NextRow())
  			pollid = query_get_id.item[1]
  		for(var/i in sql_option_list)
  			sql_option_list[i] |= list("pollid" = "'[pollid]'")
  		SSdbcore.MassInsert(format_table_name("poll_option"), sql_option_list, warn = 1)
  	log_admin("[key_name(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"] - Question: [question]")
  	message_admins("[key_name_admin(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"]<br>Question: [question]")
  