Is there a way I can check if there are any usable mysql connections?
| From: | Trond Erling Hundal | Date: | Wed, 03 Jan 2001 14:59:11 +0000 |
| Subject: | Is there a way I can check if there are any usable mysql connections? | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-5563@lists.php.net to get a copy of this message | ||
I am having trouble with some classes I am writing on.
I am creating a set of classes to show a special portion of our web site`s
newsarticles.
The problem occours when I use a search class that scans through the
articles for a spesific
word or phrase.
The search class has a bundle of functions to search generete next/prev and
format the results correctly.
The search class is an extension of another class that handles the mysql
connection.
I suspect that the problem is that each time I search, the class reconnects
and selects the db.
When I try to search a couple of times.. I suddenly get problems on my main
site, some of the news cannot be shown.
For some time ago I had the same trouble when I used a presistant connection
to MySQL.
I thought I had solved this problem now, but I was proven wrong.
Here is the sql logon function:
function sql_logon($H, $U, $P) {
// link to mYsql
$this->linkid = mysql_connect($this->H, $this->U, $this->P) ;
if (!$this->linkid) {
$this->error = "Kunne ikke logge inn på databasen" ;
$this->err_no = 1 ;
return ;
}
// select database
$result=mysql_select_db($this->sqldb,$this->linkid);
if (!$result) // unable to select db
{
$this->err= mysql_error();
$this->err_no=5;
return;
}
} // end sql_logon function.
And in the search class I use:
$this->sql_logon($H, $U, $P) ;
Is there a way to "check" if there already is a connection to MySQL that can
be used to perform the search?