ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:setcustommetatype

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
v5:reference:connection:setcustommetatype [2021/01/12 04:08] mnewnhamv5:reference:connection:setcustommetatype [2021/01/17 04:17] mnewnham
Line 9: Line 9:
          string $metaType,          string $metaType,
          string $actualType,          string $actualType,
-         mixed $handler+         string $dictionayType, 
 +         mixed $handleAsType=false, 
 +         mixed $callBack=false
          )          )
 </WRAP> </WRAP>
Line 15: Line 17:
 The function ''setCustomMetaType()'' takes an input string that represents a database-specific data type, and creates an ADOdb [[v5:dictionary:metatype|metaType]] associated with it. If the physical type is already bound to an existing metaType, the new setting overrides the old. For full functionality, a corresponding [[v5:reference:connection:setcustomactualtype|setCustomActualType()]] command should be issued. The function ''setCustomMetaType()'' takes an input string that represents a database-specific data type, and creates an ADOdb [[v5:dictionary:metatype|metaType]] associated with it. If the physical type is already bound to an existing metaType, the new setting overrides the old. For full functionality, a corresponding [[v5:reference:connection:setcustomactualtype|setCustomActualType()]] command should be issued.
 ------------------------------------------------------- -------------------------------------------------------
-===== MetaType ===== +===== $metaType ===== 
-A valid metatype +An existing or new type. The type definition should be an uppercase alpha-numeric value, e.g. **P** 
-===== ActualType ===== +===== $actualType ===== 
-A Database specific field type, mapped to the metaType  +The physical data type as provided by the database, for example the POINT data type in the mySQL returns 255.   
-===== Data Handler ===== + 
-The handler can be one of three types: +===== $dictionaryType ===== 
-  - Not set: No post processing of data prior to insertion of data +A Database specific field type, mapped to the metaType, e.g. **POINT**. This tells ADOdb how to handle the data n inserts and updates. 
-  - String: Post processing of data based on the string value of a specific [[v5:dictionary:metaType]] passed+===== $handleAsType ==== 
 +One of the standard [[v5:dictionary:dictionary_index|metaTypes]]. This indicates what type of data the new type is. If not set, then no attempt is made to process the data. 
 + 
 +=====$callback ===== 
 + 
 +The handler can be one of these types: 
 +  - Not set: No pre-processing of data prior to insertion of data.
   - Object: An anonymous function that can be used to process data.   - Object: An anonymous function that can be used to process data.
  
 +The callback function can be used to apply any changes to the data **prior** to the processing as type.
 ===== Examples ===== ===== Examples =====
 ==== Using A Passthrough Handler  ==== ==== Using A Passthrough Handler  ====
Line 42: Line 51:
 /* /*
 * Now tell ADOdb how to handle the data in inserts and updates * 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'); $ok = $db->setCustomMetaType('P','POINT');
Line 65: Line 73:
  };  };
  
-$ok = $db->setCustomMetaType('C','CHAR',$callback);+$ok = $db->setCustomMetaType('C',MYSQLI_TYPE_CHAR, 'CHAR','C', $callback);
 </code> </code>
  
Line 74: Line 82:
 * We must define the custom type before loading the data dictionary * We must define the custom type before loading the data dictionary
 */ */
-$ok = $db->setCustomActualType(255,'P'); +$ok = $db->setCustomMetaType('P', 255, 'POINT');
-$ok = $db->setCustomMetaType('P','POINT');+
  
 /* /*
v5/reference/connection/setcustommetatype.txt · Last modified: 2021/01/20 01:30 by mnewnham