Free Newsletters:
DatabaseJournal  
DBANews
Database Journal
Search Database Journal:
 
HOME News MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc Scripts Links Discussion
internet.com

» HOME
» NEWS
» FEATURES
» SERIES
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Products
Scripts
Links
» DISCUSSION
» TECH JOBS

Marketplace Partners
Be a Marketplace Partner




internet.commerce
Be a Commerce Partner
GPS
Phone Cards
Baby Photo Contest
Shop
Find Software
Holiday Gift Ideas
Free Business Cards
Home Improvement
Prepaid Phone Card
Televisions
Best Price
Promotional Products
KVM over IP
Promotional Gifts




All Talk, Little Action on 'Net Neutrality Front?

Compliance Issues Still Bedevil IT

Enterprise Spending On Virtualization To Rise

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Linked Data Planet Conference & Expo

CA ERwin® Data Modeler Proven database design and modeling. Efficiently analyze, design and deploy effective database solutions. Whitepaper: Manage SQL Server Deployments
Try it free: CA ERwin® Data Modeler


Solaris 8 Migration Assistant
Rapidly move your Solaris 8 application environments to new systems running Solaris 10 with the Solaris 8 Migration Assistant. Reduce migration risk while taking advantage of increased performance, reliability and security of the latest SPARC hardware platforms and Solaris 10 OS. »

 
Sun Eco Innovation: Good for Business, Good for the Environment
A complete solution to help you optimize and refresh your datacenter while properly recycling equipment and eliminating eWaste, including money-saving promotions to lower hardware acquisition costs. »

 
Sun Eco Innovation: Power Calculators
Power consumption has increasingly become a priority in customer's minds when purchasing new systems or storage. Sun's Power Calculators provide data on power consumption of Sun products allowing IT managers to better plan the power requirements in the datacenter to achieve better energy and cost savings. »

 
Optimize the Web Tier: Consolidate to Get More Performance in Less Space and Lower Power Consumption
Expansion in the Web tier is generally accomplished by adding more servers whenever extra capacity is needed. As the pool of servers grows larger, however, the complexity of the environment can grow exponentially. »

Production Manager (hands on)
Aquent
US-MA-Cambridge

Justtechjobs.com Post A Job | Post A Resume
PHP
June 17, 2003
An introduction to the ADOdb class library for PHP
By Ian Gilfillan

Why use a database class library?

A common beginner (and not so beginner) mistake is to develop an application without any consideration of the future. It's not impossible that one day the database you use today may be inappropriate, and you need to rewrite your application to use another database. But the PHP functions don't make your life easy when you do this - there are different functions for each DBMS - mysql_connect(), mssql_select_db(), for example. Going through all of your code and changing the functions, as well as in many cases changing the query syntax, is not a job to undertake lightly. So all too often, applications remain tied to the wrong database, inflexible and not performing optimally. That's where using a well-designed database class library can make all the difference. These allow you to change to another DBMS with minimal effort - using the same functions no matter what choice you make, with only a different connection parameter determining which DBMS to use. By removing the connection string to a single location, there is just one place to make the change. In ADOdb, for example, simply replace $db = NewADOConnection('access') with $db = NewADOConnection('mysql'), and you have an upgrade. There are a number of other class libraries out there. I've worked with many of them, but this article will focus on just one I particularly happen to like - ADOdb. This month is a brief and basic introduction to getting you up and running, while next month we'll delve a little deeper.

ADOdb currently supports MySQL, PostgreSQL, Interbase, Firebird, Informix, Oracle, MS SQL 7, Foxpro, Access, ADO, Sybase, FrontBase, DB2 and generic ODBC. If your database isn't in there, you can probably still use ADOdb generically, but spread the word, and I'm sure you won't have to wait long for it to be added.

Installing ADOdb

Installing ADOdb is extremely easy.

  • First, be sure you are running PHP version 4.0.4 or later. If you're not, I seriously suggest you upgrade!
  • Download the .zip or .tgz file from SourceForge
  • Unpack the file in the directory of your choice. This should not be in the webtree! Although the include files in ADOdb have been given the extension .inc.php, which means that poorly configured web servers that allow the serving of .inc files will not display the contents as plain text, it's still not a good idea to place libraries in the web tree. To unpack a tar file, change to the directory you want to install it in, and run tar -zxvf adodb350.tgz. This creates a directory, adodb, and numerous sub-directories.

Testing your installation

Connecting is equally easy. You can test your installation by placing the following three lines in a piece of code, replacing the variables with the appropriate values in your setup.

include("$adodb_path/adodb.inc.php"); // includes the adodb library
$db = NewADOConnection("$database_type"); // A new connection
$db->Connect("$host", "$user", "$password", "$database_name");

Now you have one successful database connection object, $db. You could also use ADONewConnection instead of NewADOConnection - the two are alternative names for the same function. The connection variables are those specific to your installation, and the database type is dependent on your DBMS. It can be one of the following:

  • access (Microsoft Access/Jet)
  • ado (Generic ADO, the base for all the other ADO drivers)
  • ado_access (Microsoft Access/Jet using ADO)
  • ado_mssql (Microsoft SQL Server using ADO)
  • db2 (DB2)
  • vfp (Microsoft Visual FoxPro)
  • fbsql (FrontBase)
  • ibase (Interbase 6 or before)
  • firebird (Firebird)
  • informix72 (Informix databases before Informix 7.3)
  • informix (Informix)
  • maxsql (MySQL with transaction support)
  • mssql (Microsoft SQL Server 7)
  • mssqlpo (Portable mssql driver)
  • mysql (MySQL without transaction support)
  • mysqlt (MySQL with transaction support, identical to maxmysql)
  • oci8 (Oracle 8/9)
  • oci805 (Oracle 8.0.5)
  • oci8po (Oracle 8/9 portable driver)
  • odbc (Generic ODBC, the base for all the other ODBC drivers)
  • odbc_mssql (MSSQL via ODBC)
  • odbc_oracle (Oracle via ODBC)
  • oracle (Oracle 7)
  • postgres (PostgreSQL)
  • postgres64 (PostgreSQL 6.4)
  • postgres7 (PostgreSQL 7, currently identical to postgres )
  • sqlanywhere (Sybase SQL Anywhere)
  • sybase (Sybase)

If you're having trouble connecting, the obvious place to look is in the path or connection values, but please make sure you can connect normally using those values before you blame ADOdb (obvious I know, but we spend most of our time fixing the obvious, so lets get it out of the way now). If you managed to connect, you are now ready to use the library in your applications.

Go to page: 1  2  Next  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

PHP Archives

Five Trends for Application Development. Download Your Complimentary Report. Exclusive. Act Now.
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers. Sponsored by HP, Citrix, and Intel.
Learn Tools & Techniques to Justify and Fund Your IT Investments. Download Complimentary Report Now!
Quest Whitepaper: Improving Oracle Database Performance Using Real-Time Visual Diagnostics
Flash Demo: Learn how IBM Information Server Blade is easy to manage, highly scalable and efficient.


Latest Forum Threads
PHP Forum
Topic By Replies Updated







JupiterOnlineMedia

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info


Legal Notices, Licensing, Reprints, & Permissions, Privacy Policy.

Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Solutions
Whitepapers and eBooks
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Microsoft Article: 7.0, Microsoft's Lucky Version?
Microsoft Article: Hyper-V--The Killer Feature in Windows Server 2008
Avaya Article: How to Feed Data into the Avaya Event Processor
Microsoft Article: Install What You Need with Windows Server 2008
HP eBook: Putting the Green into IT
Whitepaper: HP Integrated Citrix XenServer for HP ProLiant Servers
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 1
Intel Go Parallel Portal: Interview with C++ Guru Herb Sutter, Part 2--The Future of Concurrency
Avaya Article: Setting Up a SIP A/S Development Environment
IBM Article: How Cool Is Your Data Center?
Microsoft Article: Managing Virtual Machines with Microsoft System Center
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
Intel Video: Are Multi-core Processors Here to Stay?
On-Demand Webcast: Five Virtualization Trends to Watch
HP Video: Page Cost Calculator
Intel Video: APIs for Parallel Programming
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Sun Download: Solaris 8 Migration Assistant
Sybase Download: SQL Anywhere Developer Edition
Red Gate Download: SQL Backup Pro and free DBA Best Practices eBook
Red Gate Download: SQL Compare Pro 6
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
How-to-Article: Preparing for Hyper-Threading Technology and Dual Core Technology
eTouch PDF: Conquering the Tyranny of E-Mail and Word Processors
IBM Article: Collaborating in the High-Performance Workplace
HP Demo: StorageWorks EVA4400
Intel Featured Algorhythm: Intel Threading Building Blocks--The Pipeline Class
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES