v5:reference:connection:setcustommetatype
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
v5:reference:connection:setcustommetatype [2021/01/17 01:21] – mnewnham | v5:reference:connection:setcustommetatype [2021/01/20 01:30] (current) – mnewnham | ||
---|---|---|---|
Line 4: | Line 4: | ||
**From Version 5.22**\\ | **From Version 5.22**\\ | ||
==See Also== | ==See Also== | ||
- | [[v5: | + | [[v5: |
== Syntax == | == Syntax == | ||
bool setCustomMetaType( | bool setCustomMetaType( | ||
| | ||
+ | | ||
+ | | ||
mixed $handleAsType=false, | mixed $handleAsType=false, | ||
mixed $callBack=false | mixed $callBack=false | ||
Line 13: | Line 15: | ||
</ | </ | ||
===== 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 ===== |
+ | 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 ==== | ===== $handleAsType ==== | ||
- | One of the standard metaTypes. This indicates what type of data the new type is. | + | One of the standard |
- | ===== Data Handler | + | |
+ | =====$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 37: | Line 46: | ||
*/ | */ | ||
- | /* | ||
- | * First link the MySQL geometry type to a new metaType | ||
- | */ | ||
- | $ok = $db-> | ||
/* | /* | ||
- | * Now tell ADOdb how to handle the data in inserts | + | * A type ' |
- | * see the entry for setCustomMetaType for an explanation | + | * and we describe it as ' |
+ | * any changes to the input value, we do not define any processing rules | ||
*/ | */ | ||
- | $ok = $db-> | + | $ok = $db-> |
/* | /* | ||
Line 57: | Line 63: | ||
==== 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 67: | Line 73: | ||
}; | }; | ||
- | $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 89: | Line 94: | ||
COL2 C(32) NOTNULL DEFAULT ' | COL2 C(32) NOTNULL DEFAULT ' | ||
COL3 N(12.2), | COL3 N(12.2), | ||
- | | + | |
"; | "; | ||
Line 101: | Line 106: | ||
COL2 | COL2 | ||
COL3 | COL3 | ||
- | COL4 POINT, | + | COL4 JSON, |
| | ||
) | ) | ||
*/ | */ | ||
</ | </ | ||
+ | |||
+ |
v5/reference/connection/setcustommetatype.1610842894.txt.gz · Last modified: 2021/01/17 01:21 by mnewnham