i am implementing a medium size app in php using mysql/PEAR. it's design is loosely based on the orielly book book "php and mysql". yes, i'm pretty new at mysql.
each page of the authors example app begins with $conn = DB::connect($connString,true) [sic] but there is no $conn->disconnect(). sometimes my app gets a compliant (error) that i have exceeded too many connections.
in looking at the PEAR doc, i believe the 2nd param in the connect() call is incorrect, but my original coding had it that way which resulted in no complaints (???))
assuming one script per page of html output page:
1. is it proper usage to DB::connect() in each script?
2. can i save the object returned from that connect() and use it on other pages/scripts? is that the right thing to do?
3. or should each page/script start with DB::connect() and end with disconnect()?
saving the connection object like this
$_SESSION["connection"] = DB::connect($connStr)
then using it later, like this
$query = "SELECT blah blah blah..."
$result = $_SESSION["connection"]->query($query)
seems to work on some pages (in my development environment, anyway, using php4 - the actual hosting site uses php5)