p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   BOOK: Professional PHP6 (http://p2p.wrox.com/book-professional-php6-496/)
-   -   Chapter 3: class.DataManager.php for MySQL (http://p2p.wrox.com/book-professional-php6/84733-chapter-3-class-datamanager-php-mysql.html)

Naxon August 16th, 2011 04:18 AM

Chapter 3: class.DataManager.php for MySQL
Hi there,

First of all, I'm really enjoying your book until now. It has been very helpful.

The only problem is: I'm using MySQL and not PostgreSQL. It's not a problem with the queries, the only problem is with the _getConnection() method.

In order to connect to a PostgreSQL database, you only need to use the pg_connect() function, and then simply return it.

But when using MySQL, you need to first use the mysql_connect() function, and then mysql_select_db(). The mysql_connect() function is the one should be returned.

I thought about something like this:
PHP Code:

        private static function _getConnection()
            if (isset(
$hDB mysql_connect("localhost""root""") or die(mysql_error());
mysql_select_db("wrox_contactmanager"$hDB) or die(mysql_error());

Is that okay?

All times are GMT -4. The time now is 02:54 PM.

Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.