public function column($name, $params = [])
    {
        if (func_num_args() === 1) {
            if (!isset($this->_columns[$name])) {
                throw new ORMException("Unexisting column `'{$name}'`");
            }
            return $this->_columns[$name];
        }
        $column = $this->_initColumn($params);

        if ($column['type'] !== 'object' && !$column['array']) {
            $this->_columns[$name] = $column;
            return $this;
        }
        $relationship = $this->_classes['relationship'];

        $this->bind($name, [
            'type'     => $column['array'] ? 'set' : 'entity',
            'relation' => $column['array'] ? 'hasMany' : 'hasOne',
            'to'       => isset($column['class']) ? $column['class'] : Document::class,
            'link'     => $relationship::LINK_EMBEDDED,
            'config'   => isset($column['config']) ? $column['config'] : []
        ]);

        $this->_columns[$name] = $column;
        return $this;
    }
public function column($name, $params = [])
    {
        if (func_num_args() === 1) {
            if (!isset($this->_columns[$name])) {
                throw new ORMException("Unexisting column `'{$name}'`");
            }
            return $this->_columns[$name];
        }
        $column = $this->_initColumn($params);

        if ($column['type'] !== 'object' && !$column['array']) {
            $this->_columns[$name] = $column;
            return $this;
        }
        $relationship = $this->_classes['relationship'];

        $this->bind($name, [
            'type'     => $column['array'] ? 'set' : 'entity',
            'relation' => $column['array'] ? 'hasMany' : 'hasOne',
            'to'       => isset($column['class']) ? $column['class'] : Document::class,
            'link'     => $relationship::LINK_EMBEDDED,
            'config'   => isset($column['config']) ? $column['config'] : []
        ]);

        $this->_columns[$name] = $column;
        return $this;
    }
public function column ( $ name , $ params = [ ] ) { if ( func_num_args ( ) === 1 ) { if ( ! isset ( $ this -> _columns [ $ name ] ) ) { throw new ORMException ( "Unexisting column `'{$name}'`" ) ; } return $ this -> _columns [ $ name ] ; } $ column = $ this -> _initColumn ( $ params ) ; if ( $ column [ 'type' ] !== 'object' && ! $ column [ 'array' ] ) { $ this -> _columns [ $ name ] = $ column ; return $ this ; } $ relationship = $ this -> _classes [ 'relationship' ] ; $ this -> bind ( $ name , [ 'type' => $ column [ 'array' ] ? 'set' : 'entity' , 'relation' => $ column [ 'array' ] ? 'hasMany' : 'hasOne' , 'to' => isset ( $ column [ 'class' ] ) ? $ column [ 'class' ] : Document :: class , 'link' => $ relationship :: LINK_EMBEDDED , 'config' => isset ( $ column [ 'config' ] ) ? $ column [ 'config' ] : [ ] ] ) ; $ this -> _columns [ $ name ] = $ column ; return $ this ; }
Sets a field.

@param  string $name The field name.
@return object       Returns `$this`.
Sets a field .