Basic Database Class with PDO functionality Is my following (very basic) class considered good use for PDO integration?
Or is there a better, more efficient way?

class Page {

    public $title;
    public $db;

    public function __construct($title) {
        $this-&gt;title = $title;
    }

    public function connect($host, $dbname, $username, $password) {
        $this-&gt;db = new PDO('mysql:host='.$host.';dbname='.$dbname, $username, $password);
    }

    public function disconnect() {
        $this-&gt;db = null;
    }

}
Interestingly, my review is going to be all about control.

Not Enough - Public Property

Just like in the real world, public property can be used by anyone.  If your car was public property anyone could walk into your driveway and do whatever they liked with it.  When you woke up you could not expect to $this-&gt;car-&gt;drive() (What if someone had already taken it and replaced it with null?).  If they wanted to they could place a house brick in your driveway pretending that it is your car (good luck driving that).

Public properties remove the encapsulation of state from an object.  I see virtually no place for them in OO.  Protected and Private properties on the other hand are set through using the public interface (the public methods) of an object.  Importantly the public interface is testable, so you can ensure that you will not end up with a brick in your driveway unless you really want that.

Too Much - Inversion of Control

Your code will benefit from an Inversion of Conrtol (IoC).  You can read about IoC on the web.  There is a good answer on stackoverflow with code here.

With IoC and the protected properties your code becomes:

class Page {

    protected $title;
    protected $db;

    public function __construct($db, $title) {
        $this-&gt;db    = $db;
        $this-&gt;title = $title;
    }
}


Your code is no longer dependent on the specific database setup to function correctly.  Your page will use any database connection that it is given.  This has big benefits when it comes to unit testing.  See Miško Hevery - How to Think About the “new” Operator with Respect to Unit Testing.

I have another answer that covers similar things with an extra part on injecting interfaces here.