I've got a SOAP server that has several functions within it. Each one queries the database and returns data to the SOAP client.
A sample function within the SOAP server looks like this:
function getpricing($mn) {
$db = mysql_connect("mydomain", "uname", "pwd")
or die("Could not connect to the database.");
$usedb = mysql_select_db("dbname", $db);
$query = "SELECT products_price
FROM products
WHERE products_model = '".$mn."'";
$result = mysql_query($query)
or die("Could not retrieve current product from db: "
.mysql_error());
$rbc = mysql_fetch_array($result)
or die("Could not display current product for you: "
.mysql_error());
$page = $rbc[products_price];
return $page;
}
My questions:
Is it wise/necessary to do a mysql_connect within each function?
Should I use a pconnect instead or is that a waste of resources when using SOAP?