[PHP] reuse database connections
Another question about efficiency / using server resources: In another language I use, I can re-use an ODBC connection to make further queries/update/etc to the database to save the overhead of closing and reopening the connection to the db over and over. It works sometime like this (in the other language): iSQL DBNAME='xxx' LOGIN='xxx' SQL='some query' # opens the connection ... display results... iSQLMORE SQL='some other query' # reuses the connection display other results /iSQL # closes the connection Is there an equivalent in PHP to this, using the mySQL set of tags? Peter - - - - - - - - - - - - - - - - - - - - - Fourth Realm Solutions [EMAIL PROTECTED] http://www.fourthrealm.com Tel: 519-739-1652 - - - - - - - - - - - - - - - - - - - - - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reuse database connections
You can use persistent connections from php to mysql server using mysql_pconnect(host,user,passwd) then go on to use the returned link. this will open a new connection only if one is not available. kumar Support @ Fourthrealm.com wrote: Another question about efficiency / using server resources: In another language I use, I can re-use an ODBC connection to make further queries/update/etc to the database to save the overhead of closing and reopening the connection to the db over and over. It works sometime like this (in the other language): iSQL DBNAME='xxx' LOGIN='xxx' SQL='some query' # opens the connection ... display results... iSQLMORE SQL='some other query' # reuses the connection display other results /iSQL # closes the connection Is there an equivalent in PHP to this, using the mySQL set of tags? Peter - - - - - - - - - - - - - - - - - - - - - Fourth Realm Solutions [EMAIL PROTECTED] http://www.fourthrealm.com Tel: 519-739-1652 - - - - - - - - - - - - - - - - - - - - - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] reuse database connections
When you create a connection it is available to the end of the script run. You can run as many queries as you wish in the script and all will use the same connection. If you wish for multiple accesses to use the same connection, I think you will have to use persistent connections. olinux --- Kumar Lakshminarayanan [EMAIL PROTECTED] wrote: You can use persistent connections from php to mysql server using mysql_pconnect(host,user,passwd) then go on to use the returned link. this will open a new connection only if one is not available. kumar Support @ Fourthrealm.com wrote: Another question about efficiency / using server resources: In another language I use, I can re-use an ODBC connection to make further queries/update/etc to the database to save the overhead of closing and reopening the connection to the db over and over. It works sometime like this (in the other language): iSQL DBNAME='xxx' LOGIN='xxx' SQL='some query' # opens the connection ... display results... iSQLMORE SQL='some other query' # reuses the connection display other results /iSQL # closes the connection Is there an equivalent in PHP to this, using the mySQL set of tags? Peter - - - - - - - - - - - - - - - - - - - - - Fourth Realm Solutions [EMAIL PROTECTED] http://www.fourthrealm.com Tel: 519-739-1652 - - - - - - - - - - - - - - - - - - - - - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? New DSL Internet Access from SBC Yahoo! http://sbc.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php