SourceForge.net Logo

ADOdb Lite

  Home

  How to Install/Connect

  Functions Supported

  Error Handling

  Modules

blank

  Module Creation

  Sessions

  Data Dictionary

  Performance Monitor

  Debug Console

  

  ADOdb Lite Forums

  Sourceforge Forums

  Downloads

  Site Statistics

  Report a Bug

  Feature Request

  Sourceforge Summary

  

  Testimonials

  Benchmarks

  Make a Donation

  

  Subscribe to RSS Feed

  RSS File Release Feed


Sites Using ADOdb Lite

  Alien Assault Traders

  AATrade Main Game

  NAIG

  D-D-N.com

  OZNet

  Highland Springs


Special Site Links

  The Original ADOdb

  Template Lite

  poor XML wrapper


ADOdb Lite Compiled Size History

How To Install & Connect  

  Installation

Un-tar the adodb_lite??.tar.gz file into the directory that contains your website. If you are replacing ADOdb you will need to change the ADOdb path to reflect the new install.

If this is a new install you will need to add an include/require statement to the PHP files for your website.

Example:

require_once '/home/www/yourdirectory/adodb_lite/adodb.inc.php';


  Connecting to your database

You will need to designate the type of database server you will be using.

$db = ADONewConnection('databasetype');

The following databases are supported:

Databasetype Designator Database Name
fbsq Frontbase
maxdb Max DB
msql Mini SQL
mssql Microsoft SQL
mysql MySql
mysqli MySql Improved
mysqlt MySql w/transactions
postgres PostGres
postgres64 PostGres 6.4
postgres7 PostGres 7
postgres8 Postgres 8
sqlite SqLite
sqlitepo SqLite Pro
sybase Sybase
sybase_ase SyBase ASE


If the database does not exist and you would like ADOdb Lite to automatically create the database then set the createdatabase switch to true.

$db->createdatabase = true ;

If you would like for every query along with the error result echoed set the debug flag to true. The default setting is false.

$db->debug = true ;

New Connection

$result = $db->Connect("$dbhost", "$dbuname", "$dbpass", "$dbname");

or persistent connection

$result = $db->PConnect("$dbhost", "$dbuname", "$dbpass", "$dbname");

or force a new connection

$result = $db->NConnect("$dbhost", "$dbuname", "$dbpass", "$dbname");

$dbhost = localhost or url/ip address IE: http://0.0.0.0 or http://www.dbserver.com
$dbuname = The Username needed to access the database
$dbpass = Optional password for accessing the database
$dbname = The name of the database you will be accessing

 

Example:

require_once '/home/www/yourdirectory/adodb_lite/adodb.inc.php';
$db = ADONewConnection('databasetype');
$db->createdatabase = true ;
$result = $db->Connect("$dbhost", "$dbuname", "$dbpass", "$dbname");

 

  Optional Connection Flags

Mysql/Mysqli/Mysqlt:

$db->port = Port number to connect through.

$db->clientflags = The client_flags parameter can be a combination of the following constants: MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE or MYSQL_CLIENT_INTERACTIVE. (PHP 4.3.0 or higher)

 

Mysqli:

$db->socket = specifies the socket or named pipe that should be used

 

Postgres(all):

$db->port = Port number to connect through.

 

  DSN (Data Source Name) Connection Method

You can perform your driver selection and connection all at the same time if you use a DSN connection string instead of the databasetype. The DSN entry has been expanded to use the anchor symbol for the inclusion of modules.

$driver://$username:$password@$hostname/$database?options[=value]#$modules

$driver = Databasetype Designator listed in the table at the start of this page.
$username = The Username needed to access the database
$password = Optional password for accessing the database
$hostname = localhost or url/ip address IE: http://0.0.0.0 or http://www.dbserver.com
$database = The name of the database you will be accessing
$options = All Drivers - 'persist', 'persistent', 'debug', 'fetchmode'
                     Mysql (all) - 'port', 'clientflags'
                     Mysqli - 'socket'
                     Postgress (all) - 'port'
$modules = The modules that should be loaded. IE: pear, cache, extend, ect.


The following modules are supported:

Module Designator Module Function
pear Adds generic Pear Database Functions
transaction Adds transaction support for databases that support it
extend Adds little used but important ADOdb functions
date Adds all ADOdb Database Date Functions
object Adds all ADOdb Database Object Functions
menu Adds all ADOdb Database Menu Functions
adodblite Adds functions designed specifically for ADOdb Lite
meta Adds all ADOdb Database Meta Functions
perfmon Adds support for the Performance Monitor


You can use only a single command to select your driver and connect to the database instead of two command strings.

require_once '/home/www/yourdirectory/adodb_lite/adodb.inc.php';
$flags = MYSQL_CLIENT_COMPRESS;
$dsn_string = 'mysql://user:junk@localhost/mydb?persist&clientflags=$flags#pear:extend';

$db = ADONewConnection($dsn_string);

The above example would create a persistent connection to a Mysql database using the mysql driver. The User name is user, password of junk, host address is localhost, with Mysql Compression enabled, the pear and extend modules are loaded.

 

  ADOdb Lite Configuration File

ADOdb Lite uses a configuration file (adodb.config.php) to offer better compatability with ADOdb applications. You can designate the modules you need loaded when connecting to the database through the configuration file.

Example:

<?
/**
* ADOdb Lite Configuration File
*/

/**
* Set the $dbtype variable to the database designator.
* If this variable is enabled it will override the database designator
* entered in the ADONewConnection( $dbtype ) function. The database
* designator in a DSN string will be overridden but the rest of the DSN
* string will be used.
*
* You can place a DSN entry in the $dbtype variable if you would like to
* auto connect to your database.
*
* Example:
*
* $dbtype = "driver://username:password@hostname/database?options[=value]#modules";
*
* driver = Databasetype Designator listed in the table at the start of this page.
* username = The Username needed to access the database
* password = Optional password for accessing the database
* hostname = localhost or url/ip address IE: http://0.0.0.0 or http://www.dbserver.com
* database = The name of the database you will be accessing
* options = All Drivers - 'persist', 'persistent', 'debug', 'fetchmode'
* Mysql (all) - 'port', 'clientflags'
* Mysqli - 'socket'
* Postgress (all) - 'port'
* modules = The modules that should be loaded. IE: pear, cache, extend, ect.
*
*/

// $dbtype = "mysql";

/**
* If you want to maintain compatability with the ADOdb ADONewConnection( $dbtype )
* function you should designate the modules you need loaded below. If you designate
* the modules below you do not need to designate them in
* ADONewConnection( $dbtype, $modules ).
*
* If you would like more than one module loaded at the same time concatinate the
* module names using a colon (:).
*
* Example:
* $modules = "pear:transaction:extend:date";
*
* The above example would load the Pear, Transaction and Extend modules
* automatically.
*/

$modules = "pear:extend";
?>


In the above example the Pear and Extend modules will automatically be loaded when...

$db = ADONewConnection( $dbtype );

is executed. With the above change to the config file you would not need to change the ADONewConnection to...

$db = ADONewConnection( $dbtype, 'pear:extend');

This maintains 100% compatability for applications currently using ADOdb and makes it easier for them to change to ADOdb Lite.

I recommend using this configuration file for telling ADOdb Lite what modules should be used instead of using the DSN anchor tag or adding the modules to the ADONewCOnnection function. This will allow you to use ADOdb Lite with existing applications.

 

  ADOdb Modules

The one departure I am going to make from 100% compatibility with ADOdb is with modules. I have added a module system to the package that will allow you to select the modules you would like to have loaded. We will be offering two modules with this release for Transaction and Pear.

There is a second command you can use when setting up your ADOdb Lite.

$db = ADONewConnection($databasetype, $module);

The $module variable is optional.

Example:

$db = ADONewConnection('postgres7', 'transaction');

The above would load the Transaction Module for the Postgres 7 database.

The next module will be for Pear Commands.

Example:

$db = ADONewConnection('postgres7', 'pear');

If you need both modules:

$db = ADONewConnection('postgres7', 'transaction : pear');

If you need to load multiple modules you can enter as many as you want. You will need to place a colon (:) between each module in your list.

Example:

 require_once '/home/www/yourdirectory/adodb_lite/adodb.inc.php';
$db = ADONewConnection('databasetype', 'pear : transaction : cache' );
$db->createdatabase = true ;
$result = $db->Connect("$dbhost", "$dbuname", "$dbpass", "$dbname");

The above example would load the Pear, Transaction and Cache modules. This would allow you to use the commands/functions associated with those modules. There isn't a limit to how many modules that may be loaded.

I do not have a firm date for when database caching will be coming out because I do not have a firm roadmap on how I will impliment the code for database caching. I have a number of ideas that I need to try out first.

 

  Finally...

If you are familier with ADODB you will notice ADOdb Lite is started using the same parameters and commands. This makes it very easy for many sites to transfer over to ADOdb Lite.

 

 
 

Copyright ©2005 - 2007 Mark Dickenson