protected function loadForeign($column, $value)
    {
        static::checkUnknownColumn($column);

        if (!array_key_exists($column, static::FOREIGN_KEYS)) {
            throw new NotForeignColumnException(static::class, $column);
        }

        $foreign_map = static::FOREIGN_KEYS[$column];

        if ($value === null) {
            unset($this->foreign[$column]);
            return;
        }
        $foreign = ModelManager::getInstance(
            $foreign_map[0],
            [$foreign_map[1] => $value]
        );

        if ($foreign) {
            $this->foreign[$column] = $foreign;
        } else {
            throw new ForeignConstraintException(static::class, $column);
        }
    }
protected function loadForeign($column, $value)
    {
        static::checkUnknownColumn($column);

        if (!array_key_exists($column, static::FOREIGN_KEYS)) {
            throw new NotForeignColumnException(static::class, $column);
        }

        $foreign_map = static::FOREIGN_KEYS[$column];

        if ($value === null) {
            unset($this->foreign[$column]);
            return;
        }
        $foreign = ModelManager::getInstance(
            $foreign_map[0],
            [$foreign_map[1] => $value]
        );

        if ($foreign) {
            $this->foreign[$column] = $foreign;
        } else {
            throw new ForeignConstraintException(static::class, $column);
        }
    }
protected function loadForeign ( $ column , $ value ) { static :: checkUnknownColumn ( $ column ) ; if ( ! array_key_exists ( $ column , static :: FOREIGN_KEYS ) ) { throw new NotForeignColumnException ( static :: class , $ column ) ; } $ foreign_map = static :: FOREIGN_KEYS [ $ column ] ; if ( $ value === null ) { unset ( $ this -> foreign [ $ column ] ) ; return ; } $ foreign = ModelManager :: getInstance ( $ foreign_map [ 0 ] , [ $ foreign_map [ 1 ] => $ value ] ) ; if ( $ foreign ) { $ this -> foreign [ $ column ] = $ foreign ; } else { throw new ForeignConstraintException ( static :: class , $ column ) ; } }
Updates a foreign model to a new row

It tests if $column is a valid foreign column

@param string $column A column in FOREIGN_KEYS keys
@param mixed  $value  A value in the foreign table

@throws UnknownColumnException @see checkUnknownColumn()
@throws NotForeignColumnException
@throws ForeignConstraintException
Updates a foreign model to a new row