Table of Contents

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:

FieldDescription
nameThe name of the field in the database
max_lengthThe meaning of this field varies, based on the type of the field
typeThe 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 before ADOdb Version 5.21, MySQL did 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
)