function UnCastType($type, $data, &$row = null) {
		switch ($type) {
			case 'json':
				return json_encode($data);
			case 'json-import':
				if (!is_array($data))
					$data = array();
				foreach ($row as $key => $val) {
					if (substr($key, 0, 1) == '_') // Skip meta fields
						continue;
					if (!isset($this->schema[$key])) { // This key is unrecognised - import into JSON blob
						$data[$key] = $val;
						unset($row[$key]);
					}
				}
				$data = json_encode($data);
				return $data;
			default: // No idea what this is or we dont care
				return $data;
		}
	}
function UnCastType($type, $data, &$row = null) {
		switch ($type) {
			case 'json':
				return json_encode($data);
			case 'json-import':
				if (!is_array($data))
					$data = array();
				foreach ($row as $key => $val) {
					if (substr($key, 0, 1) == '_') // Skip meta fields
						continue;
					if (!isset($this->schema[$key])) { // This key is unrecognised - import into JSON blob
						$data[$key] = $val;
						unset($row[$key]);
					}
				}
				$data = json_encode($data);
				return $data;
			default: // No idea what this is or we dont care
				return $data;
		}
	}
function UnCastType ( $ type , $ data , & $ row = null ) { switch ( $ type ) { case 'json' : return json_encode ( $ data ) ; case 'json-import' : if ( ! is_array ( $ data ) ) $ data = array ( ) ; foreach ( $ row as $ key => $ val ) { if ( substr ( $ key , 0 , 1 ) == '_' ) // Skip meta fields continue ; if ( ! isset ( $ this -> schema [ $ key ] ) ) { // This key is unrecognised - import into JSON blob $ data [ $ key ] = $ val ; unset ( $ row [ $ key ] ) ; } } $ data = json_encode ( $ data ) ; return $ data ; default : // No idea what this is or we dont care return $ data ; } }
Converts a data type back into the DB format from the PHP object
@see CastType
@param string $type The type to cast from
@param mixed $data The data to convert
@param array $row Row to operate on if type requires access to its peers (e.g. 'json-import')
@return mixed The DB compatible data type
Converts a data type back into the DB format from the PHP object