class.adodb_sql.php - v1.0.0 - PHPLIB's DB_Sql format using ADODB library


    include( "./support/" ); /* ADODB library */
    include( "./support/class.adodb_sql.php" );  /* ADODB_SQL library: THIS IS A CLASS THAT YOUR ARE READING */

    class MyDBSQL extends DB_Sql {
        var $classname = "MyDBSQL";

        function MyDBSQL ( ) {
            $this->Host = "localhost";
            $this->Database = "test";
            $this->User = "";
            $this->Password = "";
            parent::driver( "mysql" );


class.adodb_sql.php permits migrating your code using DB_Sql format (PHPLIB) to an another DB engine like ADODB.


DB_Sql( [$query] )

Constructor. When creating an instance, you may optionally supply a query string

query( $query_string )

query_string is a SQL statement that is sent to the database. After sending the statement, Error and Errno are updated.
If the query is syntactically incorrect (no valid result id is being produced), halt() is called with a meaningful error message.

next_record( )

The method next_record() advances the cursor through the current query result and updates the Record, Row, Errno and Error instance variables

num_rows( ), nf( )

The method num_rows() returns the number of rows returned by the current SELECT query.

affected_rows( )

The method affected_rows() returns the number of rows affected by the current INSERT, UPDATE or DELETE query.

num_fields( )

The method num_fields() returns the number of columns returned by the current query.

np( )

The method np() prints the number of rows returned by the current query.

f( $field )

Returns the variable Record[$field].

p( $field )

Prints the variable Record[$field].

haltmsg( $msg )

This function is called by halt() and will actually print the database error message.

seek( [$pos] )

The method seek() positions the Row pointer within the result set. Useful for reading the same result set twice or otherwise jumping around within the result. $pos is not checked in any way for validity.

link_id( )

This function will return the current link ID.

query_id( )

Returns the current result ID, as returned by the query() executed internally by the database class.

metadata( [$table] [,$full] )

This method is under construction. Not implemented yet.

table_names( )

Returns an array with table name and tablespace name.


driver( $dbengine )

This function selects the database to connect.

Databases ADODB 1.2 PHPLIB 7.2d class.adodb_sql.php 1.0.0
Microsoft AccessYN-
Generic ADOYN-
Generic ODBCYY-
Visual FoxProYN-
Microsoft SQL ServerYY-
Oracle 8YY-

Note: (Y) supported, (N) not implemented, (T) tested, and (-) not tested.

The parameter $dbengine is passed to NewADOConnection() function.

connect( )

Used internally to generate a Link_ID, if necessary.

halt( $msg )

Used by query() if the initial database connection cannot be made or the target database does not exist.
Depending on the setting of Halt_On_Error, this method will call haltmsg() to report the error.

free( )

Used internally by next_record() to free the result set.


You're reading it.


class.adodb_sql.php 1.0.0 - Aug 11, 2002 © RFK Solutions <>


CopyRight (c) 2001 RFK Solutions, All Rights Reserved.

The latest version of this class should be available from the following locations:

This program is free software; you can redistribute it and/or modify it under the GNU General Artistic License, with the following stipulations;

Changes or modifications must retain these Copyright statements. Changes or modifications must be submitted to the author.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Artistic License for more details. This software is distributed AS-IS.

Address Bug Reports or Comments to RFK Solutions,

ADODB Library for PHP4
V1.20 25 June 2001 (c) 2000-2001 John Lim (

ASPDB_SQL Library for ASP

PHP Base Library
Release phplib_7_2 (c) 2000-2001 Boris Erdmann (, Kristian Köhntopp ( and Sascha Schumann (