mysql_connect() with a multi-file format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux