- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:userguide:extending

# Building Extensions

You might want to modify ADOdb for your own purposes. Luckily you can still maintain backward compatibility by sub-classing ADOdb and using the `$ADODB_NEWCONNECTION` variable. `$ADODB_NEWCONNECTION` allows you to override the behaviour of ADONewConnection(). ADOConnection() checks for this variable and will call the function-name stored in this variable if it is defined.

In the following example, new functionality for the connection object is placed in the _hack_mysql_ and _hack_postgres7_ classes. The recordset class naming convention can be controlled using $rsPrefix. Here we set it to 'hack_rs_', which will make ADOdb use _hack_rs_mysql_ and _hack_rs_postgres7_ as the recordset classes.

    class hack_mysql extends adodb_mysql {

    var $rsPrefix = 'hack_rs_';

      /* Your mods here */

    }

    class hack_rs_mysql extends ADORecordSet_mysql {

     /* Your mods here */

    }

    class hack_postgres7 extends adodb_postgres7 {

    var $rsPrefix = 'hack_rs_';

      /* Your mods here */

    }

    class hack_rs_postgres7 extends ADORecordSet_postgres7 {

     /* Your mods here */

    }

    $ADODB_NEWCONNECTION = 'hack_factory';

    function& hack_factory($driver)

    {

             if ($driver !== 'mysql' && $driver !== 'postgres7') return false;

             $driver = 'hack_'.$driver;

             $obj = new $driver();

             return $obj;

    }

    include_once('adodb.inc.php');

v5/userguide/extending.txt · Last modified: 2016/01/16 18:28 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top