Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
|
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2004, 12:13 PM
Registered User
 
Join Date: Jan 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need to disconnect from mysql?

In the 'Beginning PHP 4' book, they connect to mysql using the db_connect function. I'm a newb at this so I was wondering if we need to disconnect from mysql after we display the info we retrieved from mysql to our web site? Or does it automatically disconnect from mysql after everything is displayed on the web site?

Thanks in advance.
 
Old January 26th, 2004, 04:16 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can use mysql_close(). The beginnign PHP book probably uses wrapper functions to abstract database-specific functionality. In this case, you probably have a function called "db_disconnect()" or "db_close()".

http://www.php.net/mysql_close


Just in case you're not familiar with the term, a wrapper function is a function who's purpose is to provide a generic interface to specific functionality. For example, if you write a website that uses MySQL, but then want to switch it to Postgres or SQL Server, you'll need to rewrite ALL of your SQL function calls (connect, query, etc) to use those databases instead of MySQL.

The ideal solution would be to "wrap" all of your mysql-specific functionality in wrappers. That way, your code ONLY deals with wrapper functions (e.g. db_connect(), db_query() ). When you want to switch databases, all you have to do is rewrite the body of your wrapper functions and the rest of your site continues to function normally -- it doesn't know or care WHAT database it's connecting to, as long as the database works.


Take care,

Nik
http://www.bigaction.org/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot Disconnect DB amarjits Pro VB Databases 0 July 16th, 2007 12:27 AM
Need to disconnect database? waihung82 Pro VB 6 2 July 10th, 2006 09:54 PM
Sessions wont disconnect boxalld Apache Tomcat 0 June 2nd, 2005 10:52 AM
Automation error The object invoked has disconnect vensee Crystal Reports 0 April 11th, 2005 06:12 PM
Disconnect ADO Conn from Access DB myedu2k4 Pro VB Databases 2 May 27th, 2004 01:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.