I AM LISTENING TO
|

WHAT I LIKE

Instagantt – Gantt charts for Asana Regular Expression with TWIG / Timber to check for sticky post
Development     PHP    

Powerful database abstraction with Doctrine DBAL – Getting started



18. June 2015

“Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.”

The following will get you started, these offer the Doctrine\Common and Doctrine\DBAL namespaces.

  1. Doctrine DBAL
  2. Doctrine Common

BASIC SETUP

In the end your structure should look something like that:

includes/
includes/doctrine
includes/doctrine/lib
includes/doctrine/lib/Doctrine
includes/doctrine/lib/Doctrine/Common
includes/doctrine/lib/Doctrine/DBAL

The following will add a class loader, so that all the other classes will be autoloaded.

FIRST CONNECTION

This will setup your first connection to a MySQL database.

FIRST QUERY

This will do a simple first query

DYNAMIC & PREPARED

DBAL gives us some nice options to prepare queries.

By using the bindValue the placeholder “?” is replaced. You can also use named parameters 🙂

More about this in the official documentation.

That was not too difficult 😉

Enjoy coding …




Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz