ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:structure:addattribute

This is an old revision of the document!


addAttribute

From Version 5.21.0

See Also

Structured Schema Management
Column Attributes Reference

Syntax
obj addAttribute(
    mixed $attribute,
    optional string $platform='',
    optional integer $priority = -1;
    )

The method addAttribute() is part of the Structured Schema Management suite, and adds an attribute to the current metaObjectStructure object.

An attribute can be added to any of the available structure types, table,column,index or index-item.

Parameters

$attribute

The attribute can be provided as a string, a numeric or associative array, and can describe any parameter understood by the DBMS. For example, it might be necessary to add an option to tell the DBMS what type of database engine to use.

Platform

The platform parameter can be any parameter recognized by the Platform keyword.

Priority

The priority parameter can optionally force the system to process the attributes in a specific order. If not provided, the attributes are processed in the order provided.

Usage

In the following example, a table employees is to be created. The table is to be used in a portable environment, and require 2 platform specific attribute.

  1. Under MySQL, an engine type needs to be specified.
  2. Under IBM DB2, a tablespace needs to be specified.
$t = new metaObjectStructure($dict,'employees');
 
$t->addAttribute('ENGINE INNODB','mysql');
 
/*
* Add another platform option, for IBM DB2
*/
$t->addAttribute(array('TABLESPACE'=>'LARGE1'),'db2');

Alternatively, we can write the definition as:

$t = new metaObjectStructure($dict,'employees');
 
$t->addAttribute('ENGINE INNODB','mysql')
  ->addAttribute(array('TABLESPACE'=>'LARGE1'),'db2');
v5/dictionary/structure/addattribute.1460156740.txt.gz · Last modified: 2017/04/21 11:29 (external edit)