ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:userguide:learn_extensions:new_driver

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:userguide:learn_extensions:new_driver [2016/03/19 01:36] – ↷ Page moved and renamed from v5:userguide:extending to v5:userguide:learn_extensions:new_driver mnewnhamv5:userguide:learn_extensions:new_driver [2020/01/15 04:13] (current) mnewnham
Line 1: Line 1:
-<- v5:userguide:learn_extensions:|Start Of Lesson ^ v5:userguide:learn_extensions:start_lesson|Start Of Lesson ^ v5:learn_extensions:extend_existing:modify_existing_driver|Modifying An Existing Driver ->+<-  ^ v5:userguide:userguide_index|List Of Tutorials ^ v5:learn_extensions:extend_existing:modify_existing_driver|Modifying An Existing Driver ->
 ~~NOTOC~~ ~~NOTOC~~
 ====== Creating A New Driver ====== ====== Creating A New Driver ======
Line 35: Line 35:
   * No other action is required, simply enter the name of the new driver in the newAdoConnection() statement.   * 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:
 +
 +<code php>
 +
 +class ADOnewConnection
 +class mysql extends ADOnewConnection
 +class mysqli extends mysql
 +
 +</code>
 +But if we look at the source code of the [[v5:database:mysql|mysqli]] driver (**drivers/adodb-mysqli.inc.php**) , we can see that the class is defined like this
 +
 +<code php>
 +
 +class ADODB_mysqli extends ADOConnection {
 + var $databaseType = 'mysqli';
 + var $dataProvider = 'mysql';
 +
 +</code>
 +
 +So the class extends the connector, but much of the MySQL specific functionality is found in the **//provider//** (**drivers/adodb-mysql.inc.php**). The **provider** is effectively a parallel class. So if we wanted, for example, to create a new driver //**mydriver**// that did not directly extend an existing class, but shared much of the feature with say, the [[v5:database:microsoft_sql_server|mssqlnative]] class, our code might look like:
 +
 +<code php>
 +class ADODB_mydriver extends ADOConnection {
 + var $databaseType = 'mydriver';
 + var $dataProvider = 'mssqlnative';
 +
 +</code>
 +===== Base Level Classes =====
 +If we look at say, the [[v5:database:microsoft_sql_server|mssqlnative]] class, (**drivers/adodb-mssqlnative.inc.php**). we see the following:
 +
 +<code php>
 +class ADODB_mssqlnative extends ADOConnection {
 + var $databaseType = 'mssqlnative';
 + var $dataProvider = 'mssqlnative';
 +
 +</code>
 +
 +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/adodb-mssqlnative.inc.php**) and datadict (**datadict/datadict-mssqlnative.inc.php**) files .
 +
 +===== Using Provider Classes =====
 +Data Provider classes are designed exactly the same as database driver classes. Where the provider class is different from the database class, the provider class is generally associated with an obsolete database version, often 15-20 years old. As such, they cannot be used as drivers.
  
v5/userguide/learn_extensions/new_driver.1458347803.txt.gz · Last modified: 2017/04/21 11:40 (external edit)