one small doubt.
in a loop i have to check the username availability in database for each id.
in this case: what will be the best practice:
1. open db connection in "check_availability_function" and close db there itself
so, as each & every time when the function call - its will open & close the db connection.
2. Open db connection before loops starts and pass the connection string to required functions...
(without opening & closing connection each time function ececutes)
and finally close the connection after loop ends.