Re: Reusing MySQL Connections - Can it be done?
| From: | Matt Matijevich | Date: | Mon, 05 Apr 2004 21:39:03 +0000 |
| Subject: | Re: Reusing MySQL Connections - Can it be done? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-182407@lists.php.net to get a copy of this message | ||
[snip]
function connect_db() {
if (!defined('_CONNECT_DB')) {
$result = @mysql_pconnect("localhost", "Username",
"Password");
@mysql_select_db("database_name");
define('_CONNECT_DB', $result);
}
return _CONNECT_DB;
I call this function this way...
$query = "SELECT * FROM table";
$connid = connect_db();
$result = mysql_query($query, $connid);
[/snip]
I think you want to look into pass by reference.