Create a function that return result set
Posted: Sun Feb 14, 2010 10:19 am
Hi,
I need to create a function that takes a query statement and return a result set, here is my code:
function getResultSet($query)
{
require_once('config.php');
require_once('opendb.php');
$result = mysql_query($query);
//require_once('closedb.php');
return $result;
}
As you can see, I have to comment out the closedb.php line to make it work, but that leaves the DB connection open, which is terrible, Right? How do I make the function work and the connection closed at the same time?
TIA
I need to create a function that takes a query statement and return a result set, here is my code:
function getResultSet($query)
{
require_once('config.php');
require_once('opendb.php');
$result = mysql_query($query);
//require_once('closedb.php');
return $result;
}
As you can see, I have to comment out the closedb.php line to make it work, but that leaves the DB connection open, which is terrible, Right? How do I make the function work and the connection closed at the same time?
TIA