ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:column_attributes

This is an old revision of the document!


Dictionary Column Attributes

Add Argument Definitions

Description

When creating a column in a table using the dictionary methods, the information provided must confirm to the following specification. Each column created has a number of mandatory and optional parameters.


$fields is a string, not an array

Basic Syntax

The basic syntax of the attributes is as follows:

  • All the information for the column must occur on a single line.
  • The line ending may be a newline or carriage return/newline combination.
  • Each attribute must be separated by at least one tab or space.
  • The attributes must be specified in the order below
    1. Column Name
    2. Meta Attributes
    3. Optional Arguments
/*
 * Correct syntax
 */
$flds = "
COL1 C(60) NOTNULL DEFAULT 'abc',
COL2 I8 NOTNULL DEFAULT 0
";
 
/*
 * Incorrect syntax
 */
$flds = "
COL1 
C(60) 
NOTNULL 
DEFAULT 'abc',
COL2 
I8 
NOTNULL
DEFAULT 0
";

Attributes

Column Name

  • The column name must conform to any database specific standards related to naming and length.
  • If required, use metaCasing to control the casing and optional quoting.

Meta Attributes

  • The column attributes in terms of type and length must be specified in terms of ADODb metaType descriptions, not the database definition for the type.

Optional Arguments

The following optional arguments may also be assigned to the column, table or key. If the attribute is inappropriate for the operation or column type or not supported by the DBMS, it is ignored.


Usage: Column

AUTO

Creates the column as auto-increment. Support for this varies from one database to another. Some databases designate a field with an auto-increment flag as the primary key.

AUTOINCREMENT

Autoincrement is a synonym for AUTO


Usage: Index

CONSTRAINT


Usage: Column

DEF

DEF indicates a default value for a column when a row is created. Some databases also require a field with a default value to be designated as NOT NULL, so that is automatically added to the column string

DEFAULT

DEFAULT is a synonym for DEF

DEFDATE

DEFTIMESTAMP

INDEX

KEY

NOQUOTE


Usage: Column

NOTNULL


Usage: Index

PRIMARY


Usage: Index

UNIQUE

UNIQUE is an option against a key and indicates that duplicate values across all columns in the key are not allowed.

UNSIGNED

v5/dictionary/column_attributes.1452647184.txt.gz · Last modified: 2017/04/21 11:29 (external edit)