public function setData($data, $allowEmpty = true, $allowUnset = false)
    {
        if ($data != null) {
            if (is_array($data)) {
                $fileds = $this->getFields();
                foreach ($fileds as $field) {
                    if (isset($data[$field]) && ($allowEmpty || $data[$field] !== '')) {
                        if (strpos($this->getFieldType($field), 'varchar') !== false || $this->getFieldType($field) === 'text') {
                            $encoding = mb_detect_encoding($data[$field]);
                            if ($encoding !== 'utf8') {
                                $this->{$field} = mb_convert_encoding($data[$field], 'utf8', $encoding);
                            } else {
                                $this->{$field} = $data[$field];
                            }
                        } else {
                            $this->{$field} = $data[$field];
                        }
                    } elseif ($allowUnset) {
                        $this->{$field} = false;
                    }
                }
            } else {
                $result = $this->get($data);
                $this->setData($result->model);
                if (empty($result->model)) {
                    $this->asDefault();
                }
            }
        }
        if (empty($data)) {
            $this->asDefault();
        }
        return $this;
    }
public function setData($data, $allowEmpty = true, $allowUnset = false)
    {
        if ($data != null) {
            if (is_array($data)) {
                $fileds = $this->getFields();
                foreach ($fileds as $field) {
                    if (isset($data[$field]) && ($allowEmpty || $data[$field] !== '')) {
                        if (strpos($this->getFieldType($field), 'varchar') !== false || $this->getFieldType($field) === 'text') {
                            $encoding = mb_detect_encoding($data[$field]);
                            if ($encoding !== 'utf8') {
                                $this->{$field} = mb_convert_encoding($data[$field], 'utf8', $encoding);
                            } else {
                                $this->{$field} = $data[$field];
                            }
                        } else {
                            $this->{$field} = $data[$field];
                        }
                    } elseif ($allowUnset) {
                        $this->{$field} = false;
                    }
                }
            } else {
                $result = $this->get($data);
                $this->setData($result->model);
                if (empty($result->model)) {
                    $this->asDefault();
                }
            }
        }
        if (empty($data)) {
            $this->asDefault();
        }
        return $this;
    }
public function setData ( $ data , $ allowEmpty = true , $ allowUnset = false ) { if ( $ data != null ) { if ( is_array ( $ data ) ) { $ fileds = $ this -> getFields ( ) ; foreach ( $ fileds as $ field ) { if ( isset ( $ data [ $ field ] ) && ( $ allowEmpty || $ data [ $ field ] !== '' ) ) { if ( strpos ( $ this -> getFieldType ( $ field ) , 'varchar' ) !== false || $ this -> getFieldType ( $ field ) === 'text' ) { $ encoding = mb_detect_encoding ( $ data [ $ field ] ) ; if ( $ encoding !== 'utf8' ) { $ this -> { $ field } = mb_convert_encoding ( $ data [ $ field ] , 'utf8' , $ encoding ) ; } else { $ this -> { $ field } = $ data [ $ field ] ; } } else { $ this -> { $ field } = $ data [ $ field ] ; } } elseif ( $ allowUnset ) { $ this -> { $ field } = false ; } } } else { $ result = $ this -> get ( $ data ) ; $ this -> setData ( $ result -> model ) ; if ( empty ( $ result -> model ) ) { $ this -> asDefault ( ) ; } } } if ( empty ( $ data ) ) { $ this -> asDefault ( ) ; } return $ this ; }
Establecer estos datos al modelo, en funcion de la definicion, si no esta en la definicion no
se asigna al modelo.

@param $data
@param bool $allowEmpty
@param bool $allowUnset
@return $this
Establecer estos datos al modelo en funcion de la definicion si no esta en la definicion no se asigna al modelo .