lib/db/cortex.php
public function copyfrom($key, $fields = null) {
		$f3 = \Base::instance();
		$srcfields = is_array($key) ? $key : $f3->get($key);
		if ($fields)
			if (is_callable($fields))
				$srcfields = $fields($srcfields);
			else {
				if (is_string($fields))
					$fields = $f3->split($fields);
				$srcfields = array_intersect_key($srcfields, array_flip($fields));
			}
		foreach ($srcfields as $key => $val) {
			if (isset($this->fieldConf[$key]) && isset($this->fieldConf[$key]['type'])) {
				if ($this->fieldConf[$key]['type'] == self::DT_JSON && is_string($val))
					$val = json_decode($val);
				elseif ($this->fieldConf[$key]['type'] == self::DT_SERIALIZED && is_string($val))
					$val = unserialize($val);
			}
			$this->set($key, $val);
		}
	}
public function copyfrom($key, $fields = null) {
		$f3 = \Base::instance();
		$srcfields = is_array($key) ? $key : $f3->get($key);
		if ($fields)
			if (is_callable($fields))
				$srcfields = $fields($srcfields);
			else {
				if (is_string($fields))
					$fields = $f3->split($fields);
				$srcfields = array_intersect_key($srcfields, array_flip($fields));
			}
		foreach ($srcfields as $key => $val) {
			if (isset($this->fieldConf[$key]) && isset($this->fieldConf[$key]['type'])) {
				if ($this->fieldConf[$key]['type'] == self::DT_JSON && is_string($val))
					$val = json_decode($val);
				elseif ($this->fieldConf[$key]['type'] == self::DT_SERIALIZED && is_string($val))
					$val = unserialize($val);
			}
			$this->set($key, $val);
		}
	}
public function copyfrom ( $ key , $ fields = null ) { $ f3 = \ Base :: instance ( ) ; $ srcfields = is_array ( $ key ) ? $ key : $ f3 -> get ( $ key ) ; if ( $ fields ) if ( is_callable ( $ fields ) ) $ srcfields = $ fields ( $ srcfields ) ; else { if ( is_string ( $ fields ) ) $ fields = $ f3 -> split ( $ fields ) ; $ srcfields = array_intersect_key ( $ srcfields , array_flip ( $ fields ) ) ; } foreach ( $ srcfields as $ key => $ val ) { if ( isset ( $ this -> fieldConf [ $ key ] ) && isset ( $ this -> fieldConf [ $ key ] [ 'type' ] ) ) { if ( $ this -> fieldConf [ $ key ] [ 'type' ] == self :: DT_JSON && is_string ( $ val ) ) $ val = json_decode ( $ val ) ; elseif ( $ this -> fieldConf [ $ key ] [ 'type' ] == self :: DT_SERIALIZED && is_string ( $ val ) ) $ val = unserialize ( $ val ) ; } $ this -> set ( $ key , $ val ) ; } }
hydrate the mapper from hive key or given array
@param string|array $key
@param callback|array|string $fields
@return NULL
hydrate the mapper from hive key or given array