ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_extensions:new_driver

Creating A New Driver

The simplest way to extend ADOdb for your own use is to create a new driver. ADOdb behaves like all PHP class definitions, in that its class methods and variables can be extended. As an example, we can look at the ADOdb driver /drivers/adodb-odbc-mssql2012.inc.php

This driver was created because the behaviour of Microsoft SQL Server 2012 differs slightly from previous versions when connecting via an ODBC connection.

The driver, in it's entirety, looks like this:

/**
*  Microsoft SQL Server 2012 via ODBC
*/
 
if (!defined('ADODB_DIR')) 
	die();
 
include_once(ADODB_DIR."/drivers/adodb-odbc_mssql.inc.php");
 
class  ADODB_odbc_mssql2012 extends ADODB_odbc_mssql
{
	/*
	* Makes behavior similar to prior versions of SQL Server
	*/
	var $connectStmt = 'SET CONCAT_NULL_YIELDS_NULL ON';
}
 
class  ADORecordSet_odbc_mssql2012 extends ADORecordSet_odbc_mssql
{
}
  • Both the connection and recordset classes must be defined, even if they are not modified
  • The driver must be located in the ADODB_DIR directory. Take care that the driver is not lost when upgrading
  • No other action is required, simply enter the name of the new driver in the newAdoConnection() statement.
v5/userguide/learn_extensions/new_driver.txt · Last modified: 2016/03/19 01:50 by mnewnham