making a global connection
Posted: Wed Nov 23, 2005 4:02 am
Hi i have a function
db_connect() which connects to my database
at the moment for every query in my application i am calling the function, is there a way to make this function global so i dont have to call it all the time?.
Also wondered as I have tens of queries, could all these connections affect perfromance?
thanks in advance
db_connect() which connects to my database
Code: Select all
function db_connect()
{
$result = mysql_connect('localhost', 'user', 'password') or exit ("can't connect to database");
if(!$result)
return false;
if(!mysql_select_db('db'))
return false;
return $result;
}Also wondered as I have tens of queries, could all these connections affect perfromance?
thanks in advance