ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:setactualtype

setActualType

From ABOdb V5.21

See Also

getActualType()
metaType()

Syntax
bool setActualType(
    string $metaType,
    string $actualType,
    optional bool $newType
)

Description

The method setActualType() either modifies the database specific data type for a given metaType, or provides the ability to create a new one. The returned value indicates the success of the operation.

If the method is used to create a new actualType, then the optional bool $newType must be set.

A connection to a data dictionary object is required, but a database connection is not.

Usage

In this example we want to change the behavior of the mssqlnative driver, so that instead of the default datetime type associated with the D metatype, we want to use data dictionary functions to create a more portable date type (available since SQL Server 2008).

$db = newAdoConnection('mssqlnative');
$dict = NewDataDictionary($db);
 
$dict->setActualType('D','DATE');

In the second example, we will create a new actual type so that we can use the ADOdb dictionary function to create tables containing geospatial information.

$db = newAdoConnection('mysqli');
$dict = NewDataDictionary($db);
 
$dict->setActualType('G','GEOMETRY',true); //must provide optional 3rd argument
$dict->setActualType('P','POINT',true);
 
/*
 * Add 2 new columns to table
*/
$columns = 'GEODATA_COL G, POINTDATA_COL P';
$sqlarray = $dict->addColumnSql('POSITION_TABLE',$columns);
 
print_r($sqlarray);
 
/*
 * Prints
Array
(
 [0] => ALTER TABLE POSITION_TABLE ADD GEODATA_COL GEOMETRY
 [1] => ALTER TABLE POSITION_TABLE ADD POINTDATA_COL POINT
)
*/
v5/dictionary/setactualtype.txt · Last modified: 2017/07/22 18:39 by mnewnham