# check if challenge exists update if so else insert.
UNIQUE_ID=$(mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "SELECT id FROM ${PDNS_Database}.records WHERE name='${full}' AND type='TXT'")
if[[ -z "${UNIQUE_ID}"]];then
mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "INSERT INTO ${PDNS_Database}.records \
(name, content, type,ttl,prio) VALUES \
('${full}','${txtvalue}','TXT',120,NULL);"
else
mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "UPDATE ${PDNS_Database}.records SET content='${txtvalue}' \
WHERE id='${UNIQUE_ID}' AND name='${full}' AND type='TXT' LIMIT 1;"
fi
_domain_id=$(mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "SELECT id FROM ${PDNS_Database}.domains WHERE name='${root}'")
# insert challenge.
mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "INSERT INTO ${PDNS_Database}.records (domain_id,name, content, type,ttl,prio) VALUES \
_delete_challenge=$(mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "DELETE FROM ${PDNS_Database}.records WHERE name='${full}'")
if[ -z "$_delete_challenge"];then
_err "Delete txt record error."
return1
fi
mysql -ss "-h${PDNS_Host}""-P${PDNS_Port}""-u${PDNS_User}""-p${PDNS_Pass}" -e "DELETE FROM ${PDNS_Database}.records WHERE name='${full}' AND type='TXT';"