Migrated to Doctrine ORM

Migrated database access to Doctrine ORM.