v5:reference:connection:setcustommetatype
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
v5:reference:connection:setcustommetatype [2021/01/17 00:41] – [Data Handler] mnewnham | v5:reference:connection:setcustommetatype [2021/01/18 04:02] – mnewnham | ||
---|---|---|---|
Line 3: | Line 3: | ||
<WRAP right box> | <WRAP right box> | ||
**From Version 5.22**\\ | **From Version 5.22**\\ | ||
- | ==See Also== | ||
- | [[v5: | ||
== Syntax == | == Syntax == | ||
bool setCustomMetaType( | bool setCustomMetaType( | ||
| | ||
| | ||
- | mixed $handler | + | string $dictionayType, |
+ | mixed $handleAsType=false, | ||
+ | mixed $callBack=false | ||
) | ) | ||
</ | </ | ||
===== Description ===== | ===== Description ===== | ||
- | The function '' | + | The function '' |
------------------------------------------------------- | ------------------------------------------------------- | ||
- | ===== MetaType | + | ===== $metaType |
- | An existing or new type. | + | An existing or new type. The type definition should be an uppercase alpha-numeric value, e.g. **P** |
- | ===== ActualType | + | |
- | A Database specific field type, mapped to the metaType | + | ===== $actualType ===== |
- | ===== Data Handler | + | The physical data type as provided by the database, for example the POINT data type in the mySQL returns 255. |
+ | |||
+ | ===== $dictionaryType | ||
+ | A Database specific field type, mapped to the metaType, e.g. **POINT**. This tells ADOdb how to handle the database will handle the record. | ||
+ | |||
+ | ===== $handleAsType | ||
+ | One of the standard [[v5: | ||
+ | |||
+ | =====$callback ===== | ||
The handler can be one of these types: | The handler can be one of these types: | ||
- Not set: No pre-processing of data prior to insertion of data. | - Not set: No pre-processing of data prior to insertion of data. | ||
Line 35: | Line 44: | ||
*/ | */ | ||
- | /* | ||
- | * First link the MySQL geometry type to a new metaType | ||
- | */ | ||
- | $ok = $db-> | ||
/* | /* | ||
- | * Now tell ADOdb how to handle the data in inserts and updates | + | * A type ' |
- | * see the entry for setCustomMetaType for an explanation | + | |
*/ | */ | ||
- | $ok = $db-> | + | $ok = $db-> |
/* | /* | ||
Line 55: | Line 59: | ||
==== Using a closure ==== | ==== Using a closure ==== | ||
- | In this example all character fields are converted to lowercase by the anonymous function | + | In this example all character fields are converted to lowercase by the anonymous function, and are then processed normally as character |
<code php> | <code php> | ||
Line 65: | Line 69: | ||
}; | }; | ||
- | $ok = $db-> | + | $ok = $db-> |
</ | </ | ||
===== Using The Custom Type In DataDict Functions ====== | ===== Using The Custom Type In DataDict Functions ====== | ||
- | In this example, we use a custom definition to create a POINT column in a table under MySQL | + | In this example, we use a custom definition to create a JSON column in a table under MySQL |
<code php> | <code php> | ||
/* | /* | ||
* We must define the custom type before loading the data dictionary | * We must define the custom type before loading the data dictionary | ||
*/ | */ | ||
- | $ok = $db-> | + | $ok = $db-> |
- | $ok = $db-> | + | |
/* | /* | ||
Line 87: | Line 90: | ||
COL2 C(32) NOTNULL DEFAULT ' | COL2 C(32) NOTNULL DEFAULT ' | ||
COL3 N(12.2), | COL3 N(12.2), | ||
- | | + | |
"; | "; | ||
Line 99: | Line 102: | ||
COL2 | COL2 | ||
COL3 | COL3 | ||
- | COL4 POINT, | + | COL4 JSON, |
| | ||
) | ) | ||
*/ | */ | ||
</ | </ | ||
+ | |||
+ |
v5/reference/connection/setcustommetatype.txt · Last modified: 2021/01/20 01:30 by mnewnham