I have multiple php functions for my code and each function tries to setup mysql connection, send queries and closes mysql connection. Is this a good design or should I set up one connection from a master function and then pass the variables to each of these functions to execute queries?
Also, is it possible that this code will give errors when trying to execute the 2nd instance of mysql_query in func1() ? Won't the instance of mysql connection called in func2 be independent from the instance called in func1? In my code, I seem to get inconsistent behaviors. At times, I am getting error but when I refresh the page, there seems to be no problem. Any suggestions is welcome. Thanks.
def func1() {
mysql_connect(params)
mysql_query()
func2()
mysql_query()
mysql_close()
}
def func2() {
mysql_connect(params)
mysql_query()
mysql_close()
}