- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:dictionary:adofieldobject

# adoFieldObject

## Description

When the metacolumns method is executed by ADOdb, the data retrieved is placed in an array of adoFieldObjects. This is a class based around the following format:

    class ADOFieldObject {
         var $name = '';
         var $max_length = 0;
         var $type="";
    }

Individual databases may extend the object, but the basic information is as follows:

Field | Description
--- | ---
name | The name of the field in the database
max_length | The meaning of this field varies, based on the type of the field
type | The type of the field as described by the database. In order to retrieve the portable type this value must be sent to the metatype method, and the return value used.

## Sample Of Program To Retrieve ADOFieldObjects

    $SQL = "SELECT * FROM some_table";
    $f = $db->Execute($SQL);
    $cols = $f->fieldCount();
    for($i=0;$i<$cols;$i++){
        $fld = $f->FetchField($i);
        print_r($fld);
    }

## Examples

### SQL Server

    ADOFieldObject Object
    (
      [name] => Freight
      [max_length] =>
      [column_source] => Freight
      [type] => decimal
    )

    ADOFieldObject Object
    (
      [name] => ShipName
      [max_length] => 40
      [column_source] => ShipName
      [type] => nvarchar
    )

### IBM DB2

    ADOFieldObject Object
    (
      [name] => ACTNO
      [max_length] => 6
      [type] => int
    )

    ADOFieldObject Object
    (
      [name] => ACTKWD
      [max_length] => 6
      [type] => string
    )

### MySQL

Note that currently, MySql does not return an ADOfieldObject object.

    stdClass Object
    (
      [name] => Code
      [orgname] => Code
      [table] => country
      [orgtable] => country
      [def] =>
      [db] => world
      [catalog] => def
      [max_length] => 3
      [length] => 9
      [charsetnr] => 33
      [flags] => 16387
      [type] => 254
      [decimals] => 0
      [primary_key] => 2
      [not_null] => 1
      [auto_increment] => 0
      [binary] => 0
      [unsigned] => 0
    )

## Sqlite

    ADOFieldObject Object
    (
      [name] => COL1
      [max_length] => 32
      [type] => VARCHAR
      [not_null] => 1
      [default_value] => 'abc'
      [scale] => 0
     )

    ADOFieldObject Object
    (
       [name] => COL2
       [max_length] => 10
       [type] => DECIMAL
       [not_null] => 0
       [default_value] => 0
       [scale] => 0
    )

    ADOFieldObject Object
    (
       [name] => COL3
       [max_length] => 12,2
       [type] => DECIMAL
       [not_null] => 0
       [default_value] =>
       [scale] => 0
    )

v5/dictionary/adofieldobject.txt · Last modified: 2016/01/16 18:11 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top