Database Abstraction Layer for PHP

User Tools

Site Tools


The MetaType

The lowest level of information that ADOdb supports is the MetaType. This object represents the type of field in a consistent, simplified format.

Actual Types

Data is stored in the database in fields that best represent the type of data, e.g. Integer, character, floating point. These types may be subclassed further, e.g Small,Medium,Large integers. In addition, there may be estoric field types such as geometry, points etc. ADOdb refers to these types as Actual Types.

In total, ADOdb knows about 150 different Actual data types, and can simplify them down to 9 MetaTypes.

Type Represents Field Types
C character fields that should be shown in a <input type=“text”> tag
X TeXt, large text or CLOB fields that should be shown in a <textarea>
B Blobs, or Binary Large Objects. Typically images.
D Date (sometimes DateTime) field
T Timestamp field
L Logical field (boolean or bit-field). Some databases emulate logicals using I2 fields
I Integer field, This may be broken down further into I2,I4 or I8 types to represent small,medium and large integers. The largest integer data size is always represented by an I field
N Numeric field. Includes autoincrement, numeric, floating point, real and integer.
R Serial field. Includes serial, autoincrement integers. This works for selected databases. Some databases do not signify if a field is auto-increment

If ADOdb encounters a field type that it does not know about, It provides a method of defaulting the field handling.

Using MetaTypes

PHP programs often include code that branches based on the type of data available, for example to format numbers based on whether they are integer or floating point. Using the MetaType simplifies the branching by representing possibly 5-10 Actual Types of Floating Point numbers with a single Metatype, N.

The next page in the lesson will show how to retrieve and use MetaTypes

v5/userguide/learn_dictionary/metatypes.txt · Last modified: 2016/03/17 00:08 by mnewnham