[PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Monty
I am trying to use fewer resources and processes when making database connections in my scripts, so, upon the first call to make a DB connection, I store the Link Resource ID in a constant variable that can be accessed by all other functions that need a DB connection, like this... function

Re: [PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Matt Matijevich
[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

Re: [PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Monty
It appears you can't pass constant vars by reference, or am I missing your point? I understand passing vars by reference, but not sure where you suggest I need to use it. I tried define('_CONNECT_DB', $result); and return _CONNECT_DB; separately, but neither worked. [snip] function connect_db()

Re: [PHP] Reusing MySQL Connections - Can it be done?

2004-04-05 Thread Richard Harb
Monday, April 5, 2004, 11:23:29 PM, you wrote: I am trying to use fewer resources and processes when making database connections in my scripts, so, upon the first call to make a DB connection, I store the Link Resource ID in a constant variable that can be accessed by all other functions that