Re: [Fwd: Re: [PEAR-DEV] serialize datatype for MDB2]

From: Date: Fri, 09 Jun 2006 11:17:17 +0000
Subject: Re: [Fwd: Re: [PEAR-DEV] serialize datatype for MDB2]
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-42883@lists.php.net to get a copy of this message
Hi, I have added two new options into CVS. 1) 'datatype_map': this essentially adds the ability to map a custom datatype to a native datatype. So for example $mdb2->setOptions('datatype_map', array('email' => 'text')); 2) 'datatype_map_callback': to keep the number of if's in normal operation low, this is only checked incase the given datatype has been mapped using the 'datatype_map' option. if there is also a callback defined for the given mapped type, then the given callback method is called. So the idea is that you can then implement something like serialize as a callback. function serialize_callback(&$db, $method, parameters) { switch($method) {
    case 'quote':
      $value = serialize($parameters['value']);
      return $db->datatype->quote($value, 'text');
    case 'convertResult':
      $value = $db->datatype->convertResult($parameters['value'], 'text');
      return @unserialize($value);
    case 'getDeclaration':
      return $db->datatype->getDeclaration('text', $parameters['name'], $parameters['field']);
    case 'mapPrepareDatatype':
      return 'text';
} } I have not tested this yet, just pondering .. regards, Lukas

« previous php.pear.dev (#42883) next »