选择语言 :

 Core_Config::delete

删除制定key的配置,支持多个

boolean Core_Config::delete( string/array $key [, string $type = empty ] )

参数列表

参数 类型 描述 默认值
$key string/array $key
$type string $type empty
返回值
  • boolean
File: ./core/classes/config.class.php
public function delete($key, $type='')
{
    $db = new Database($this->database);
    $type = (string)$type;
    try
    {
        if (is_array($key))
        {
            # 多个key
            $db->where('type', $type);
            $db->and_where_open();
            foreach ($key as $k)
            {
                $db->or_where('key_md5', $k);
                if ($this->config)unset($this->config[$type][$k]);
            }
            $db->and_where_close();
            $db->delete();
        }
        else
        {
            # 单个key
            $db->delete($this->tablename, array('type'=>$type, 'key_md5'=>md5($key)));
            if ($this->config)unset($this->config[$type][$key]);
        }

        // 删除缓存
        $this->clear_cache();
        return true;
    }
    catch (Exception $e)
    {
        return false;
    }
}