ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:adofieldobject

This is an old revision of the document!


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 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.1452996668.txt.gz · Last modified: 2017/04/21 11:29 (external edit)