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/06 02:39] 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.
 ------------------------------------------------------- -------------------------------------------------------
-===== Data Handler ===== +===== $metaType ===== 
-The handler can be of three types: +An existing or new type. The type definition should be an uppercase alpha-numeric value, e.g. **P** 
-  Not set: No post processing of data prior to insertion of data +===== $actualType ===== 
-  - String: Post processing of data based on metaType passedThe string value must be that of a valid metaType +The physical data type as provided by the database, for example the POINT data type in the mySQL returns 255.  
-  - Object: An anonymous function that can be used to process data+
  
 +===== $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.
 +===== $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.
 +
 +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 38: 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 61: Line 73:
  };  };
  
-$ok = $db->setCustomMetaType('C','CHAR',$callback);+$ok = $db->setCustomMetaType('C',MYSQLI_TYPE_CHAR, 'CHAR','C', $callback);
 </code> </code>
  
Line 70: 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