选择语言 :

 Module_OOP_ORM_Data::__unset

销毁指定key的值

null Module_OOP_ORM_Data::__unset( string $key )

参数列表

参数 类型 描述 默认值
$key string $key
File: ./modules/oop/orm/data.class.php
public function __unset($key)
{
    # 获取当前设置
    $config = $this->_get_offset_config($key);
    if ( ! $config )
    {
        return;
    }

    $offset_exist = isset($this->_offset_data[$key]);

    if ( $this->_orm_data_is_created )
    {
        # 对象已构造完毕
        if ( $offset_exist && $config['is_readonly'] )
        {
            if ( null!==$this->_offset_data[$key] && false!==$this->_offset_data[$key] )
            {
                # 只读字段不允许设置
                return false;
            }
        }
    }

    # 映射字段
    if ( isset($config['_parent_offset_name']) )
    {
        # 设置数据
        if ( false === $this->__unset($config['_parent_offset_name']) )
        {
            return false;
        }
        else
        {
            return true;
        }
    }

    unset($this->_has_set_offset[$key]);
    unset($this->_offset_data[$key]);
    unset($this->_created_offset[$key]);

    if ( isset($config['_all_sub_offset']) && is_array($config['_all_sub_offset']) )
    {
        foreach ($config['_all_sub_offset'] as $sub_key)
        {
            unset($this->_has_set_offset[$sub_key]);
            unset($this->_offset_data[$sub_key]);
            unset($this->_created_offset[$sub_key]);
        }
    }

    return true;
}