check if a certain field exists in the mapper or
or is a virtual relation field
@param string $key
@param bool $relField
@return bool
187480
function exists($key, $relField = false) {
		if (!$this->dry() && $key == '_id') return true;
		return $this->mapper->exists($key) ||
			($relField && isset($this->fieldConf[$key]['relType']));
	}
1324122
protected static function resolveRelationConf($field,$pkey=NULL) {
		if (array_key_exists('belongs-to-one', $field)) {
			// find primary field definition
			if (!is_array($relConf = $field['belongs-to-one']))
				$relConf = array($relConf, '_id');
			// set field type
			if ($relConf[1] == '_id')
				$field['type'] = Schema::DT_INT4;
			else {
				// find foreign field type
				$fc = $relConf[0]::resolveConfiguration();
				$field['belongs-to-one']['relPK'] = $fc['primary'];
				$field['type'] = $fc['fieldConf'][$relConf[1]]['type'];
			}
			$field['nullable'] = true;
			$field['relType'] = 'belongs-to-one';
		}
		elseif (array_key_exists('belongs-to-many', $field)){
			$field['type'] = self::DT_JSON;
			$field['nullable'] = true;
			$field['relType'] = 'belongs-to-many';
		}
		elseif (array_key_exists('has-many', $field)){
			$field['relType'] = 'has-many';
			if (!isset($field['type']))
				$field['type'] = Schema::DT_INT;
			$relConf = $field['has-many'];
			if(!is_array($relConf))
				return $field;
			$rel = $relConf[0]::resolveConfiguration();
			if(array_key_exists('has-many',$rel['fieldConf'][$relConf[1]])) {
				// has-many <> has-many (m:m)
				$field['has-many']['hasRel'] = 'has-many';
				$field['has-many']['isSelf'] = (ltrim($relConf[0],'\\')==get_called_class());
				$field['has-many']['relTable'] = $rel['table'];
				$field['has-many']['relField'] = $relConf[1];
				$field['has-many']['relFieldType'] = isset($rel['fieldConf'][$relConf[1]]['type']) ?
					$rel['fieldConf'][$relConf[1]]['type'] : Schema::DT_INT;
				$field['has-many']['relPK'] = isset($relConf['relPK'])?
					$relConf['relPK']:$rel['primary'];
				$field['has-many']['localKey'] = isset($relConf['localKey'])?
					$relConf['localKey']:($pkey?:'_id');
			} else {
				// has-many <> belongs-to-one (m:1)
				$field['has-many']['hasRel'] = 'belongs-to-one';
				$toConf=$rel['fieldConf'][$relConf[1]]['belongs-to-one'];
				$field['has-many']['relField'] = is_array($toConf) ?
					$toConf[1] : $rel['primary'];
			}
		} elseif(array_key_exists('has-one', $field))
			$field['relType'] = 'has-one';
		return $field;
	}
346285
public function HasField ($fieldOrFieldName = NULL) {
		$fieldName = NULL;
		if ($fieldOrFieldName instanceof \MvcCore\Ext\Forms\IField) {
			$fieldName = $fieldOrFieldName->GetName();
		} else if (is_string($fieldOrFieldName)) {
			$fieldName = $fieldOrFieldName;
		}
		return isset($this->fields[$fieldName]);
	}
657267
protected function _unserializeFindField($field, $key, &$result, Model $Model) {
		if (isset($result[$field])) {
			$result[$field] = $this->_unserialize($Model->alias, $result[$field]);
		} elseif ($key === $field) {
			$result = $this->_unserialize($Model->alias, $result);
		} else {
			foreach ($this->_getAliases($Model) as $alias) {
				if (isset($result[$alias][$field])) {
					$result[$alias][$field] = $this->_unserialize($Model->alias, $result[$alias][$field]);
				} elseif (isset($result[$alias]) && is_array($result[$alias])) {
					foreach ($result[$alias] as $_key => &$_result) {
						$this->_unserializeFindField($field, $_key, $_result, $Model);
					}
				}
			}
		}
	}
1352343
public function getRelationshipKey($field)
	{
		$model = $this->config->getDataModel();
		$invalidArgument = new \InvalidArgumentException("The '" . $field . "' relationship field you supplied for " .
								$this->config->getOption('name') . " is not a valid relationship method name on the supplied Eloquent model");

		//check if the related method exists on the model
		if (!method_exists($model, $field))
		{
			throw $invalidArgument;
		}

		//now that we know the method exists, we can determine if it's multiple or single
		$related_model = $model->{$field}();

		//check if this is a valid relationship object, and return the appropriate key
		if (is_a($related_model, $this->relationshipBase.'BelongsTo'))
		{
			return 'belongs_to';
		}
		else if (is_a($related_model, $this->relationshipBase.'BelongsToMany'))
		{
			return 'belongs_to_many';
		}
		else if (is_a($related_model, $this->relationshipBase.'HasOne'))
		{
			return 'has_one';
		}
		else if (is_a($related_model, $this->relationshipBase.'HasMany'))
		{
			return 'has_many';
		}
		else
		{
			throw $invalidArgument;
		}
	}
16434
public function keyExists($key)
    {
        $exists = true;
        try {
            $this->get($key);
        } catch (Exception $e) {
            $exists = false;
        }
        return $exists;
    }
646246
public function hasParam($field) {
        foreach ($this->getParams() as $param) {
            if ($param instanceof Expr && $param->getField() === $field) {
                return true;
            }
        }

        return false;
    }
646818
public function __isset($key)
    {
        if (method_exists($this, 'get' . Convention::toPascal($key) . 'Attribute')) {
            return true;
        }

        if ($this->keyExists($key)) {
            return true;
        }

        if ($this->relationExists($key)) {
            return true;
        }

        $entity = $this->getEntity();
        if (method_exists($entity, $key)) {
            return true;
        }

        if ($entity->getRepository()->getCache()->tableHasField($entity->getTable(), $key)) {
            return true;
        }

        foreach (get_class_methods($entity) as $method) {
            if (substr($method, 0, 7) == '__isset' && substr($method, -9) == 'Extension') {
                if ($entity->$method($key)) {
                    return true;
                }
            }
        }

        return false;
    }
1083677
public function hexists($key, $field) {

        $set = $this->get($key, array());

        return isset($set[$field]);
    }
354564
public function contains( $key, $returnIfFound = true )
    {
        if ( null !== ( $_value = $this->get( $key ) ) )
        {
            if ( true !== $returnIfFound )
            {
                $_value = true;
            }

            return $_value;
        }

        return false;
    }
884792
public function hasMapping($key)
    {
        if (is_null($this->mappedAttributes)) {
            $this->parseMappings();
        }

        return array_key_exists((string) $key, $this->mappedAttributes);
    }
732938
public function isUploadField($key)
    {
        return array_key_exists($key, $this->uploadGetKeys) || array_key_exists($key, $this->uploadSetKeys);
    }
120206
function castField($key, $rel_depths=0) {
		if (!$key)
			return NULL;
		$mapper_arr = $this->get($key);
		if(!$mapper_arr)
			return NULL;
		$out = array();
		foreach ($mapper_arr as $mp)
			$out[] = $mp->cast(null,$rel_depths);
		return $out;
	}
300748
public function has( $key ) {
		return isset( $this->recordFields[$key] ) || array_key_exists( $key, $this->recordFields );
	}
1362144
public function valueExists($field, $value = null)
    {
        $record = new static($this->table, $this->keys, $this->mapper);

        if ($value === null) {
            $value = $this->$field;
        }

        try {
            $record->load([$field => $value]);
        } catch (NoResultException $e) {
            return false;
        }

        if ($record->$field != $value) {
            return false;
        }

        // check record keys same as self
        $same = [];

        foreach ($this->keys as $key) {
            $same[] = ($record->$key == $this->$key);
        }

        // Key not same, means same value exists in other record.
        if (in_array(false, $same, true)) {
            return true;
        }

        return false;
    }
1332005
public function hasPropertyKey($key)
    {
        /** @var \yii\db\ActiveRecord|\DevGroup\DataStructure\traits\PropertiesTrait $owner */
        $owner = $this->owner;
        $owner->ensurePropertiesAttributes();
        return in_array($key, $owner->propertiesAttributes);
    }
1257464
public function hasVal($key) {
        return isset($this->field[$key]) || (is_array($this->field) && array_key_exists($key, $this->field));
    }