ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:setcustomactualtype

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
v5:reference:connection:setcustomactualtype [2021/01/12 03:58] mnewnhamv5:reference:connection:setcustomactualtype [2021/01/18 03:59] (current) – removed mnewnham
Line 1: Line 1:
-====== setCustomActualType ====== 
-~~NOTOC~~ 
-<WRAP right box> 
-**From Version 5.22**\\ 
-==See Also== 
-[[v5:reference:connection:setcustommetatype|setCustomMetaType]]\\ 
-== Syntax == 
-  bool setCustomActualType( 
-         string $actualType, 
-         string $metaType 
-         ) 
-</WRAP> 
-===== Description ===== 
-The function ''setCustomActualType()'' takes an input string that represents a database-specific data type, and creates an ADOdb [v5:dictionary:metattype|metaType]] associated with it. If the physical type is already bound to an existing metaType, the new setting overrides the old setting. For full functionality, a corresponding [[v5:reference:connection:setcustommetatype|setCustomMetaType()]] command should be issued. 
- 
-===== Examples ===== 
-==== Creating A New Type ==== 
-The system can be expanded to accept geometry type data types by creating new types 
-<code php> 
- 
-/* 
-* $db = MySQL connection assumed 
-*/ 
- 
-/* 
-* First link the MySQL geometry type to a new metaType 
-*/  
-$ok = $db->setCustomActualType(255,'P'); 
- 
-/* 
-* Now tell ADOdb how to handle the data in inserts and updates 
-* see the entry for setCustomMetaType for an explanation 
-*/ 
-$ok = $db->setCustomMetaType('P','POINT'); 
- 
-/* 
-* Insert a record with a point column 
-*/ 
-$ar = array(); 
-$ar['geo_column'] = 'POINT(1,2)'; 
- 
-/* 
-* Use getinsertsql to generate the insert statement 
-*/ 
-$sql = "SELECT * FROM geo_table WHERE rowid=0"; 
-$result = $db->execute($sql); 
- 
-$sql = $db->getInsertSql($result,$ar); 
- 
-/* 
-* returns "INSERT INTO geo_table ( GEO_COLUMN ) VALUES ( POINT(1,2) )" 
-*/ 
-</code> 
- 
-===== Overriding An Existing Type ===== 
-The system can be used to control the behavior of existing types. For example, in ADOdb V5.22, the **D** metaType in the Microsoft SQL Server points to Physical DATE type field, instead of the DATETIME field previously used. To make code compatible with previous versions, the following method can be used. 
-<code php> 
- 
-/* 
-* $db = SQL Server connection assumed 
-*/ 
- 
-/* 
-* Point the actual type to a D metatype. 
-*/ 
-$db->setCustomActualType(SQLSRV_SQLTYPE_DATETIME2 , 'D'); 
- 
-/* 
-* Next, point the metaType D back to the datetime2 type, and tell it  
-* to handle the data as datetime 
-*/ 
-$db->setCustomActualType('D', SQLSRV_SQLTYPE_DATETIME2, 'T'); 
-</code> 
  
v5/reference/connection/setcustomactualtype.1610420313.txt.gz · Last modified: 2021/01/12 03:58 by mnewnham