ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:dictionary:setactualtype

This is an old revision of the document!


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 values 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 types so that we can use the adodb dictionary function to create tables containing geospatial information.

$db = newAdoConnection('mysql');
$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 G, POINTDATA P';
$sqlarray = $dict->addColumnSql('POSITION',$columns);
 
print_r($sqlarray);
 
/*
 * Prints
Array
(
 [0] => ALTER TABLE POSITION ADD GEODATA GEOMETERY
 [1] => ALTER TABLE POSITION ADD POINTDATA POINT
)
*/
v5/dictionary/setactualtype.1494714134.txt.gz · Last modified: 2017/05/14 00:22 by mnewnham