components/Config.php
public function set($name, $value = null)
    {
        if (is_array($name)) {
            $insert = [];
            $delete = [];

            foreach ($name as $key => $val) {
                $val = $this->_merge($key, $val);
                $insert[] = [$key, $val];
                $delete[] = $key;

                $this->_data[$key] = $val;
            }
            if (count($insert) > 0) {
                $this->_db->createCommand()->delete($this->tableName, ['IN', 'name', $delete])->execute();
                $this->_db->createCommand()->batchInsert($this->tableName, ['name', 'value'], $insert)->execute();
            }
        } else {
            $value = $this->_merge($name, $value);

            if (array_key_exists($name, $this->getData()) === false) {
                $this->_db->createCommand()->insert($this->tableName, ['name' => $name, 'value' => $value])->execute();
            } else {
                $this->_db->createCommand()->update($this->tableName, ['value' => $value], 'name = :name', [':name' => $name])->execute();
            }
            $this->_data[$name] = $value;
        }

        $this->_setCache();
    }
public function set($name, $value = null)
    {
        if (is_array($name)) {
            $insert = [];
            $delete = [];

            foreach ($name as $key => $val) {
                $val = $this->_merge($key, $val);
                $insert[] = [$key, $val];
                $delete[] = $key;

                $this->_data[$key] = $val;
            }
            if (count($insert) > 0) {
                $this->_db->createCommand()->delete($this->tableName, ['IN', 'name', $delete])->execute();
                $this->_db->createCommand()->batchInsert($this->tableName, ['name', 'value'], $insert)->execute();
            }
        } else {
            $value = $this->_merge($name, $value);

            if (array_key_exists($name, $this->getData()) === false) {
                $this->_db->createCommand()->insert($this->tableName, ['name' => $name, 'value' => $value])->execute();
            } else {
                $this->_db->createCommand()->update($this->tableName, ['value' => $value], 'name = :name', [':name' => $name])->execute();
            }
            $this->_data[$name] = $value;
        }

        $this->_setCache();
    }
public function set ( $ name , $ value = null ) { if ( is_array ( $ name ) ) { $ insert = [ ] ; $ delete = [ ] ; foreach ( $ name as $ key => $ val ) { $ val = $ this -> _merge ( $ key , $ val ) ; $ insert [ ] = [ $ key , $ val ] ; $ delete [ ] = $ key ; $ this -> _data [ $ key ] = $ val ; } if ( count ( $ insert ) > 0 ) { $ this -> _db -> createCommand ( ) -> delete ( $ this -> tableName , [ 'IN' , 'name' , $ delete ] ) -> execute ( ) ; $ this -> _db -> createCommand ( ) -> batchInsert ( $ this -> tableName , [ 'name' , 'value' ] , $ insert ) -> execute ( ) ; } } else { $ value = $ this -> _merge ( $ name , $ value ) ; if ( array_key_exists ( $ name , $ this -> getData ( ) ) === false ) { $ this -> _db -> createCommand ( ) -> insert ( $ this -> tableName , [ 'name' => $ name , 'value' => $ value ] ) -> execute ( ) ; } else { $ this -> _db -> createCommand ( ) -> update ( $ this -> tableName , [ 'value' => $ value ] , 'name = :name' , [ ':name' => $ name ] ) -> execute ( ) ; } $ this -> _data [ $ name ] = $ value ; } $ this -> _setCache ( ) ; }
Sets configuration variable

@param $name
@param mixed $value
@return mixed
Sets configuration variable