v5:userguide:learn_extensions:new_driver
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v5:userguide:extending [2016/01/17 03:28] – ↷ Page moved from v5:reference:extending to v5:userguide:extending mnewnham | v5:userguide:learn_extensions:new_driver [2020/01/15 04:13] (current) – mnewnham | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | <- ^ v5: |
- | You might want to modify | + | ~~NOTOC~~ |
+ | ====== | ||
+ | The simplest way to extend | ||
- | In the following example, new functionality for the connection | + | This driver was created because |
+ | The driver, in it's entirety, looks like this: | ||
<code php> | <code php> | ||
- | class hack_mysql extends adodb_mysql { | + | /** |
+ | * Microsoft SQL Server 2012 via ODBC | ||
+ | */ | ||
- | var $rsPrefix = 'hack_rs_'; | + | if (!defined('ADODB_DIR')) |
+ | die(); | ||
- | /* Your mods here */ | + | include_once(ADODB_DIR." |
- | } | + | 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 hack_rs_mysql | + | class |
+ | { | ||
+ | } | ||
+ | </ | ||
- | /* Your mods here */ | + | |
+ | | ||
+ | * No other action is required, simply enter the name of the new driver in the newAdoConnection() statement. | ||
- | } | + | ===== Understanding The Data Provider ===== |
+ | Because ADOdb V5 is not truly Object Orientated, an extended driver does not necessarily extend the required parent. One might expect to see the following chain of code: | ||
- | class hack_postgres7 extends adodb_postgres7 { | + | <code php> |
- | var $rsPrefix = ' | + | class ADOnewConnection |
+ | class mysql extends ADOnewConnection | ||
+ | class mysqli extends mysql | ||
- | /* Your mods here */ | + | </code> |
+ | But if we look at the source code of the [[v5: | ||
- | } | + | <code php> |
- | class hack_rs_postgres7 | + | class ADODB_mysqli |
+ | var $databaseType = ' | ||
+ | var $dataProvider = ' | ||
- | /* Your mods here */ | + | </code> |
- | } | + | So the class extends the connector, but much of the MySQL specific functionality is found in the **// |
- | $ADODB_NEWCONNECTION | + | <code php> |
+ | class ADODB_mydriver extends ADOConnection { | ||
+ | var $databaseType | ||
+ | var $dataProvider = ' | ||
- | function& | + | </ |
+ | ===== Base Level Classes ===== | ||
+ | If we look at say, the [[v5: | ||
- | { | + | <code php> |
+ | class ADODB_mssqlnative extends ADOConnection | ||
+ | var $databaseType = ' | ||
+ | var $dataProvider = ' | ||
- | if ($driver !== ' | + | </ |
- | | + | In this case, the **$databaseType** and the **$dataProvider** are the same. This means that all of the functionality of the driver is provided by the named driver (**drivers/ |
- | $driver | + | ===== Using Provider Classes ===== |
- | + | Data Provider classes are designed exactly the same as database | |
- | $obj = new $driver(); | + | |
- | + | ||
- | return $obj; | + | |
- | + | ||
- | } | + | |
- | + | ||
- | include_once(' | + | |
- | </ | + | |
v5/userguide/learn_extensions/new_driver.txt · Last modified: 2020/01/15 04:13 by mnewnham