[PHP-DB] mysql_connect() with a multi-file format

2005-06-22 Thread Doug Hernandez
I'm new to PHP, due to having been all hard-nosed and obtuse about
using Perl/CGI.
I've been looking for a good way to pick up php tricks and what-nots,
so I joined the list.

That said, I have an immediate question.

I have a multi-file script:

main.php requires_once config.php, and so on.  I'd like to have a
data.php file that handles function wrappers for database and also
establishes a connection to the db.

I read in the php.net manual that the connection closes automatically
when the script exits.  Does this mean I can't open a db connection in
one file and pass the link around from function to function?

ie:

require_once 'data.php'; // data.php contains a mysql_connect()
// after this line, is my link closed?
require_once 'blah.php' ;

OR:
require_once 'data.php'; // with wrapper data_connection() 

$save_this_link = data_connection() ; // will this work?
some_function( $save_this_link ) ; //etc.

-- 
Douglas Hernandez
(612) 229-9684

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] mysql_connect() with a multi-file format

2005-06-22 Thread Chris Ramsay
 I read in the php.net manual that the connection closes automatically
 when the script exits.  Does this mean I can't open a db connection in
 one file and pass the link around from function to function?

No, the script you include becomes part of the main script calling the
inclusion, therefore the connection stays open 'til you explicitly
close it, or your main script exits.

cheers

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php