public function setFieldValueByDbKey(Entity $entity, $dbFieldName, $value)
	{
		$this->getTableSchema();
		if (!array_key_exists('db_to_field', $this->cache) && !array_key_exists($dbFieldName, $this->cache['db_to_field'])) {
			throw new \Exception('There is no field mapped to ' . $dbFieldName . ' in ' . get_class($this));
		}
		$fieldName = $this->cache['db_to_field'][$dbFieldName];
		$method = 'set' . ucfirst($fieldName);

		/** @var Column $columnSchema */
		$columnSchema = $this->cache['columns'][$fieldName];
		if ($columnSchema->getType() == 'Array') {
			if (!is_array($value)) {
				$value = $value ? json_decode($value, true) : [];
			}
		} elseif ($columnSchema->getType() == 'Boolean') {
			$value = $value ? true : false;
		}

		$entity->$method($value);
	}
public function setFieldValueByDbKey(Entity $entity, $dbFieldName, $value)
	{
		$this->getTableSchema();
		if (!array_key_exists('db_to_field', $this->cache) && !array_key_exists($dbFieldName, $this->cache['db_to_field'])) {
			throw new \Exception('There is no field mapped to ' . $dbFieldName . ' in ' . get_class($this));
		}
		$fieldName = $this->cache['db_to_field'][$dbFieldName];
		$method = 'set' . ucfirst($fieldName);

		/** @var Column $columnSchema */
		$columnSchema = $this->cache['columns'][$fieldName];
		if ($columnSchema->getType() == 'Array') {
			if (!is_array($value)) {
				$value = $value ? json_decode($value, true) : [];
			}
		} elseif ($columnSchema->getType() == 'Boolean') {
			$value = $value ? true : false;
		}

		$entity->$method($value);
	}
public function setFieldValueByDbKey ( Entity $ entity , $ dbFieldName , $ value ) { $ this -> getTableSchema ( ) ; if ( ! array_key_exists ( 'db_to_field' , $ this -> cache ) && ! array_key_exists ( $ dbFieldName , $ this -> cache [ 'db_to_field' ] ) ) { throw new \ Exception ( 'There is no field mapped to ' . $ dbFieldName . ' in ' . get_class ( $ this ) ) ; } $ fieldName = $ this -> cache [ 'db_to_field' ] [ $ dbFieldName ] ; $ method = 'set' . ucfirst ( $ fieldName ) ; /** @var Column $columnSchema */ $ columnSchema = $ this -> cache [ 'columns' ] [ $ fieldName ] ; if ( $ columnSchema -> getType ( ) == 'Array' ) { if ( ! is_array ( $ value ) ) { $ value = $ value ? json_decode ( $ value , true ) : [ ] ; } } elseif ( $ columnSchema -> getType ( ) == 'Boolean' ) { $ value = $ value ? true : false ; } $ entity -> $ method ( $ value ) ; }
Sets class field value by DB field name

@param Entity $entity
@param $dbFieldName
@param $value
@throws \Exception
Sets class field value by DB field name