More query caching improvements.
Added lastInsertId() function to the DB class.
Initial commit of entity traits.

These are a set of traits designed to provide support for creating
models that should contain data from database tables.

It's currently untested.