O'Reilly logo

PHP Programming with PEAR by Stoyan Stefanov, Carsten Lucke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending MDB2

MDB2 is easy to tweak by playing with its numerous setup options, but it's also highly extensible. For example, you can wrap the query results in your custom classes, when you execute a query or fetch data. You can create your own debug handler, provide your own Iterator implementation, and finally, you can add new functionality to the package by creating new modules in addition to the existing ones. In this section you'll see the necessary steps for creating custom functionality.

Custom Debug Handler

You already know that you can set the debug option to a positive integer like this:

$mdb2->setOption('debug', 1);

Then at any time you can get a list of executed queries like this:

$mdb2->getDebugOutput();

You can provide your own custom ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required