View Single Post
  #1 (permalink)  
Old August 16th, 2011, 04:18 AM
Naxon Naxon is offline
Registered User
Join Date: Aug 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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?