Database
  Home arrow Database arrow Page 2 - Accessing Databases with ADODB
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Accessing Databases with ADODB
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 37
    2004-08-02

    Table of Contents:
  • Accessing Databases with ADODB
  • Connecting, Queries and Quoting
  • Introducing Record Sets
  • Retrieving Multiple Rows
  • Understanding Error Handling
  • Generating HTML
  • More HTML Generation
  • Printing
  • Splitting Data Across Multiple Pages
  • Pivot Tables
  • Caching
  • Exporting Data

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Accessing Databases with ADODB - Connecting, Queries and Quoting


    (Page 2 of 12 )

    The Connect() method calls the appropriate underlying PHP functions to connect to the appropriate database. ADODB also has a PConnect() method to establish a persistent connection to the database. This is supported for Oracle, MySQL, PostgreSQL, Microsoft SQL Server, and ODBC. The tests/testdatabases.inc.php file in the ADODB distribution includes lots of example syntax for Connect() and PConnect() with the different kinds of databases that ADODB supports. Table 2-1 lists the driver strings that can be passed to ADONewConnection() and the databases to which they correspond. Because some databases have multiple driver string possibilities, check the online ADODB manual at http://php.weblogs.com/adodb_manual for the latest details on a particular driver string.

     

    Driver String

    Database

    adoA generic ADO database

    access

    Microsoft Access

    ado_access

    Microsoft Access via ADO

    vfp

    Visual FoxPro

    db2

    DB2

    fbsql

    FrontBase

    ibase

    InterBase 6 or earlier

    firebird

    InterBase (Firebird version)

    borland_ibase

    InterBase 6.5 or later (Borland version)

    informix72

    Informix 7.2 or earlier

    informix

    Informix

    mysql

    MySQL (without transaction support)

    mysqlt

    MySQL (with transaction support)

    maxsql Same as mysqlt
    oci8 Oracle 8 and 9
    oci805 Oracle 8.0.5
    oci8po Oracle 8 and 9*
    odbc_oracle Oracle via ODBC
    odbc An ODBC DSN
    postgres7 PostgreSQL 7
    postgres64 PostgreSQL 6.4 and earlier
    postgres Same as postgres7
    sapdb SAPDB via ODBC
    sqlanywhere SQLAnywhere via ODBC
    sqlite SQLite (only available with PHP 5)
    mssql Microsoft SQL Server 7 or later
    mssqlpo Microsoft SQL Server 7 or later**
    ado_mssql Microsoft SQL Server via ADO
    odbc_mssql Microsft SQL Server via ODBC
    sybase Sybase

    Table 2-1. ADODB Driver Strings and Databases

    Table notes:
    * Uses ? for bind variables in Prepare() and lowercase for field names
    ** Converts the || concatenation operator to +

    Queries and Quoting

    The Execute() method is the central way in ADODB to send a query to the database server. In its simplest form, as used previously, you pass Execute() an SQL query, and it returns a record set that holds the results. You can also use placeholders with Execute(). Any question marks in your query are replaced with values from an array passed to Execute() as a second argument. The question marks are placeholders for the values that come from the array. This technique is useful if you need to run similar queries repeatedly:

    $sql = 'SELECT * FROM ice_cream WHERE flavor LIKE ?';
    // Get information about Chocolate
    $rs = $conn->execute($sql,array('Chocolate'));
    // Get information about Vanilla
    $rs = $conn->execute($sql,array('Vanilla'));

    Placeholders also make quoting easier. String values substituted for placeholders are surrounded by single quotes and have single quotes in them escaped in the appropriate manner for the database you’re using. If you’re not using placeholders, you can quote values with the qstr() method:

    $flavor = $conn->qstr($_REQUEST['flavor']);
    $rs = $conn->execute("SELECT * FROM ice_cream WHERE flavor LIKE $flavor");

    This is from Essential PHP Tools, by David Sklar (Apress, ISBN 1590592808). Check it out at your favorite bookstore today. Buy this book now.

    More Database Articles
    More By Apress Publishing


       · i want the programming code for the add delete update useing the adodb ontrols.
     

    DATABASE ARTICLES

    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client
    - ADO`s Stream Object
    - Opening a Record Object Referencing an Open ...
    - Introducing Jasper (SQL Anywhere 10 Beta)
    - Creating a Database Project in VS 2005

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT