GapOrm/Mapper/BaseModel.php
private function convertFromDB($obj)
    {
        foreach ($this->fields as $field) {
            switch ($field->type()) {
                case self::FIELD_TYPE_BOOL :
                    $obj->{$field->identifier()} = (bool) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_INT :
                    $obj->{$field->identifier()} = (int) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_FLOAT :
                    $obj->{$field->identifier()} = (float) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_STR :
                    break;
                case self::FIELD_TYPE_DATETIME :
                    if ($obj->{$field->identifier()} === '0') {
                        $obj->{$field->identifier()} = false;
                    } else {
                        $d = new \DateTime();
                        if (!is_object($obj->{$field->identifier()})) {
                            $d->setTimestamp($obj->{$field->identifier()});
                            $obj->{$field->identifier()} = $d;
                        }

                        $obj->{$field->identifier()} = $d;
                    }
                    break;
                case self::FIELD_TYPE_STR_ARRAY :
                    $delimiter = '(^!)';
                    if (empty($obj->{$field->identifier()}))
                        $obj->{$field->identifier()} = [];
                    else
                        $obj->{$field->identifier()} = array_map(function($v) use ($delimiter) {
                            return stripslashes($v);
                        }, explode($delimiter, $obj->{$field->identifier()}));
                    break;
                case self::FIELD_TYPE_INT_ARRAY :
                    $arr = empty($obj->{$field->identifier()})
                        ? [] : explode(',', $obj->{$field->identifier()});
                    $obj->{$field->identifier()} = array_map(function($v) { return (int) str_replace('\'', '', $v); }, $arr);
                    break;
                case self::FIELD_TYPE_OBJ :
                    $obj->{$field->identifier()} = empty($obj->{$field->identifier()})
                        ? new \StdClass() : json_decode($obj->{$field->identifier()});
                    break;
                default :
                    throw new TypeNotExistException();
            }
        }

        return $obj;
    }
private function convertFromDB($obj)
    {
        foreach ($this->fields as $field) {
            switch ($field->type()) {
                case self::FIELD_TYPE_BOOL :
                    $obj->{$field->identifier()} = (bool) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_INT :
                    $obj->{$field->identifier()} = (int) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_FLOAT :
                    $obj->{$field->identifier()} = (float) $obj->{$field->identifier()};
                    break;
                case self::FIELD_TYPE_STR :
                    break;
                case self::FIELD_TYPE_DATETIME :
                    if ($obj->{$field->identifier()} === '0') {
                        $obj->{$field->identifier()} = false;
                    } else {
                        $d = new \DateTime();
                        if (!is_object($obj->{$field->identifier()})) {
                            $d->setTimestamp($obj->{$field->identifier()});
                            $obj->{$field->identifier()} = $d;
                        }

                        $obj->{$field->identifier()} = $d;
                    }
                    break;
                case self::FIELD_TYPE_STR_ARRAY :
                    $delimiter = '(^!)';
                    if (empty($obj->{$field->identifier()}))
                        $obj->{$field->identifier()} = [];
                    else
                        $obj->{$field->identifier()} = array_map(function($v) use ($delimiter) {
                            return stripslashes($v);
                        }, explode($delimiter, $obj->{$field->identifier()}));
                    break;
                case self::FIELD_TYPE_INT_ARRAY :
                    $arr = empty($obj->{$field->identifier()})
                        ? [] : explode(',', $obj->{$field->identifier()});
                    $obj->{$field->identifier()} = array_map(function($v) { return (int) str_replace('\'', '', $v); }, $arr);
                    break;
                case self::FIELD_TYPE_OBJ :
                    $obj->{$field->identifier()} = empty($obj->{$field->identifier()})
                        ? new \StdClass() : json_decode($obj->{$field->identifier()});
                    break;
                default :
                    throw new TypeNotExistException();
            }
        }

        return $obj;
    }
private function convertFromDB ( $ obj ) { foreach ( $ this -> fields as $ field ) { switch ( $ field -> type ( ) ) { case self :: FIELD_TYPE_BOOL : $ obj -> { $ field -> identifier ( ) } = ( bool ) $ obj -> { $ field -> identifier ( ) } ; break ; case self :: FIELD_TYPE_INT : $ obj -> { $ field -> identifier ( ) } = ( int ) $ obj -> { $ field -> identifier ( ) } ; break ; case self :: FIELD_TYPE_FLOAT : $ obj -> { $ field -> identifier ( ) } = ( float ) $ obj -> { $ field -> identifier ( ) } ; break ; case self :: FIELD_TYPE_STR : break ; case self :: FIELD_TYPE_DATETIME : if ( $ obj -> { $ field -> identifier ( ) } === '0' ) { $ obj -> { $ field -> identifier ( ) } = false ; } else { $ d = new \ DateTime ( ) ; if ( ! is_object ( $ obj -> { $ field -> identifier ( ) } ) ) { $ d -> setTimestamp ( $ obj -> { $ field -> identifier ( ) } ) ; $ obj -> { $ field -> identifier ( ) } = $ d ; } $ obj -> { $ field -> identifier ( ) } = $ d ; } break ; case self :: FIELD_TYPE_STR_ARRAY : $ delimiter = '(^!)' ; if ( empty ( $ obj -> { $ field -> identifier ( ) } ) ) $ obj -> { $ field -> identifier ( ) } = [ ] ; else $ obj -> { $ field -> identifier ( ) } = array_map ( function ( $ v ) use ( $ delimiter ) { return stripslashes ( $ v ) ; } , explode ( $ delimiter , $ obj -> { $ field -> identifier ( ) } ) ) ; break ; case self :: FIELD_TYPE_INT_ARRAY : $ arr = empty ( $ obj -> { $ field -> identifier ( ) } ) ? [ ] : explode ( ',' , $ obj -> { $ field -> identifier ( ) } ) ; $ obj -> { $ field -> identifier ( ) } = array_map ( function ( $ v ) { return ( int ) str_replace ( '\'' , '' , $ v ) ; } , $ arr ) ; break ; case self :: FIELD_TYPE_OBJ : $ obj -> { $ field -> identifier ( ) } = empty ( $ obj -> { $ field -> identifier ( ) } ) ? new \ StdClass ( ) : json_decode ( $ obj -> { $ field -> identifier ( ) } ) ; break ; default : throw new TypeNotExistException ( ) ; } } return $ obj ; }
Check & convert Fields for Select

@param $obj
@return mixed
@throws \GapOrm\Exceptions\TypeNotExistException
Check & convert Fields for Select