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 04:11] – [Using a closure] 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( | ||
Line 15: | Line 15: | ||
</ | </ | ||
===== Description ===== | ===== Description ===== | ||
- | The function '' | + | The function '' |
------------------------------------------------------- | ------------------------------------------------------- | ||
===== $metaType ===== | ===== $metaType ===== | ||
An existing or new type. The type definition should be an uppercase alpha-numeric value, e.g. **P** | An existing or new type. The type definition should be an uppercase alpha-numeric value, e.g. **P** | ||
+ | |||
===== $actualType ===== | ===== $actualType ===== | ||
The physical data type as provided by the database, for example the POINT data type in the mySQL returns 255. | The physical data type as provided by the database, for example the POINT data type in the mySQL returns 255. | ||
===== $dictionaryType ===== | ===== $dictionaryType ===== | ||
- | A Database specific field type, mapped to the metaType, e.g. **POINT**. This tells ADOdb how to handle the data n inserts and updates. | + | 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 [[v5: | + | One of the standard [[v5: |
- | ===== 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 42: | 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 ' |
+ | * and we describe it as ' | ||
+ | * any changes to the input value, we do not define any processing rules | ||
*/ | */ | ||
- | $ok = $db-> | + | $ok = $db-> |
/* | /* | ||
Line 61: | 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 75: | Line 77: | ||
===== 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-> |
/* | /* | ||
Line 92: | Line 94: | ||
COL2 C(32) NOTNULL DEFAULT ' | COL2 C(32) NOTNULL DEFAULT ' | ||
COL3 N(12.2), | COL3 N(12.2), | ||
- | | + | |
"; | "; | ||
Line 104: | Line 106: | ||
COL2 | COL2 | ||
COL3 | COL3 | ||
- | COL4 POINT, | + | COL4 JSON, |
| | ||
) | ) | ||
*/ | */ | ||
</ | </ | ||
+ | |||
+ |
v5/reference/connection/setcustommetatype.1610853117.txt.gz · Last modified: 2021/01/17 04:11 by mnewnham