保存数据

@return array
350134
public function actionSave()
    {
        $link_id = \Yii::$app->request->post('link_id');
        $menu_id = \Yii::$app->request->post('menu_id');
        $url_id = \Yii::$app->request->post('url_id');
        $status = \Yii::$app->request->post('status');

        if (!DpAdminMenuUrl::getByUrlId($url_id)) {
            return $this->renderError('菜单URL不存在！');
        }
        $saveData = [
            'menu_id' => $menu_id,
            'url_id' => $url_id,
            'status' => $status,
        ];
        if ($link_id) {
            $obj = DpAdminMenuUrlRelation::find()
                ->findByLinkId($link_id)
                ->one();
            if (!$obj) {
                return $this->renderError('保存失败，记录不存在！');
            }
        } else {
            $obj = new DpAdminMenuUrlRelation();
        }
        $obj->setAttributes($saveData);
        if (!$obj->save()) {
            foreach ($obj->getErrors() as $error) {
                foreach ($error as $message) {
                    return [
                        'success' => false,
                        'msg' => $message,
                    ];
                }
            }
        }

        return $this->renderSuccess('保存成功');
    }
1119018
protected function save()
    {
        $this->flash()->ageFlashData();

        $values = $this->values;

        $values[self::METADATA_NAMESPACE] = [
            'firstTrace' => $this->getFirstTrace(),
            'lastTrace' => $this->getLastTrace(),
            'regenerationTrace' => $this->getRegenerationTrace(),
            'requestsCount' => $this->getRequestsCount(),
            'fingerprint' => $this->getFingerprint(),
        ];

        return $this->getStore()->save($this->getId(), $values, $this->ttl);
    }
1232209
public function persist()
    {
        $parts = explode('/', $this->file);
        array_pop($parts);

        $dir = implode('/', $parts);

        if (!is_dir($dir)) {
            mkdir($dir, 493, true);
        }

        return file_put_contents($this->file, serialize($this->data));
    }
529574
public function save()
    {
        if (!empty($this->ltiResultSourcedId) && !is_null($this->resourceLink)) {
            $ok = $this->resourceLink->getConsumer()->getStorage()->userSave($this);
        } else {
            $ok = true;
        }

        return $ok;
    }
45933
public function save()
    {
        $data = $this->getData();
        if (!$this->currentId)
        {
            $config = $this->getConfig();
            $config->last_id++;
            $this->tableFields->{$this->databaseConfig->getIdentifier()} = $config->last_id;
            array_push($data,$this->tableFields);
            $this->databaseConfig->put($config);
        }
        else
        {
            $this->tableFields->{$this->databaseConfig->getIdentifier()} = $this->currentId;
            $data[$this->currentKey]    = $this->tableFields;
        }
        $this->databaseDocument->put($data);
        return (!$this->currentId) ? $this->setFields() : $this;
    }
836162
public function save()
	{
		$result = $this->getClient()->save();
		$ids = array( 'catalog' );

		foreach( $this->getView()->param( 'category/catalog.id', [] ) as $id ) {
			$ids[] = 'catalog-' . $id;
		}

		$this->getContext()->getCache()->deleteByTags( $ids );

		return $result;
	}
984960
public function save()
    {
        foreach ($this->_update as $mbox => $val) {
            try {
                if (!empty($val['u'])) {
                     $ptr = &$this->_data[$mbox];
                     foreach ($this->_getMsgCids($mbox, array_keys($val['u'])) as $k2 => $v2) {
                         try {
                             $this->_hash->set(
                                 $v2,
                                 $this->_pack->pack($ptr[$k2]),
                                 array('expire' => $this->_params['lifetime'])
                             );
                         } catch (Horde_Pack_Exception $e) {
                             $this->deleteMsgs($mbox, array($v2));
                             $val['d'][] = $v2;
                         }
                     }
                 }

                 if (!empty($val['d'])) {
                     $this->_hash->delete(array_values(
                         $this->_getMsgCids($mbox, $val['d'])
                     ));
                 }

                 if (!empty($val['m'])) {
                     try {
                         $this->_hash->set(
                             $this->_getCid($mbox),
                             $this->_pack->pack($this->_mbox[$mbox]),
                             array('expire' => $this->_params['lifetime'])
                         );
                     } catch (Horde_Pack_Exception $e) {}
                 }
            } catch (Horde_Exception $e) {
            }
        }

        $this->_update = array();
    }
992098
public function save()
	{
		$data = $this->get('details');

		if ($data instanceof Registry)
		{
			$this->set('details', $data->toString());
		}
		else if (!is_string($data))
		{
			$this->set('details', json_encode($data));
		}

		$isNew = $this->isNew();
		$result = parent::save();

		if ($result)
		{
			Event::trigger('activity.onLogSave', [$this, $isNew]);
		}

		return $result;
	}
1010210
public function save()
    {
        $this->_dsql()->owner->beginTransaction();
        $this->hook('beforeSave');

        // decide, insert or modify
        if ($this->loaded()) {
            $res = $this->modify();
        } else {
            $res = $this->insert();
        }

        $res->hook('afterSave');
        $this->_dsql()->owner->commit();

        return $res;
    }
156485
public function save()
	{
		$result=true;
		foreach($this->files as $file)
		{
			if($this->confirmed($file))
				$result=$file->save() && $result;
		}
		return $result;
	}
1318869
public function saveconfig(){
		$fields=$this->getallfields();
		foreach($fields as $k=>&$v){
			$v->value=BRequest::getVar($k,$v->default);
			}
		$cfgfile='<?php'.PHP_EOL;
		foreach($fields as $fld){
			$cfgfile.=$fld->getcfg();
			}
		$fn_config=BROOTPATH.'config'.DIRECTORY_SEPARATOR.'config.php';
		return file_put_contents($fn_config,$cfgfile);
		}
158291
public function store()
    {
        $input      = Input::all();
        $user       = auth()->user();
        $attributes = [
            'user_id' => $user->hasRoles('member') ? $user->id : array_get($input, 'user'),
            'name'    => array_get($input, 'name'),
            'value'   => array_only($input, ['field_1', 'field_2'])
        ];

        $model = new ModuleRow($attributes);
        $form  = $this->form($model);
        if (!$form->isValid()) {
            return redirect_with_errors(handles('antares::sample_module/index/create'), $form->getMessageBag());
        }
        if (!$model->save()) {
            event('notifications.item_has_not_been_created', ['variables' => ['user' => $user, 'item' => $model]]);
            return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.save_error'), 'error');
        }
        event('notifications.item_has_been_created', ['variables' => ['user' => $user, 'item' => $model]]);
        return redirect_with_message(handles('antares::sample_module/index'), trans('antares/sample_module::messages.save_success'), 'success');
    }
28787
public function save()
    {
        $operations = [];

        $this->items->each(function ($item) use(&$operations) {
          $operation = $this->setOperator();
          $operation->setOperand($item);
          $operation->setOperator('SET');

          $operations[] = $operation;
        });

        if(empty($operations))
            return false;

        return $this->adWordsServices->mutate($operations)->getValue();
    }
800382
public function saveFiles()
    {
        $fileFields = $this->getFileFields();

        foreach ($fileFields as $fieldName => $options) {
            $file = Request::file($fieldName);
            if ($file instanceof UploadedFile && $file->isValid()) {
                $filename = $file->getClientOriginalName();
                $fileSavePath = $this->getFileSavePath($options['dirName']);

                $file->move($fileSavePath, $filename);

                $this->attributes[$fieldName] = $fileSavePath.$filename;
            }
        }
    }
1003359
public function save(){
		$json	= $this->data->toJson();
		if( $this->format )
			$json	= ADT_JSON_Formater::format( $json );
		return FS_File_Writer::save( $this->fileName, $json );
	}
146581
public function save()
    {
        /**
         * 使用PHP Sesion，Readonl，未启动 这3种情况下不需要保存
         */
        if ($this->use_php_session or !$this->isStart or $this->readonly)
        {
            return true;
        }
        //设置为Session关闭状态
        $this->isStart = false;
        $key = self::$cache_prefix . $this->sessID;
        return $this->cache->set($key, serialize($_SESSION), $this->session_lifetime);
    }
795856
public static function save()
    {
        $path = RUNTIME_PATH . Config::get('log.path') . DS;

        if (!is_dir($path)) {
            File::createFolder($path);
        }

        if (isset($_SERVER['HTTP_HOST'])) {
            $current_uri = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
        } else {
            $current_uri = "cmd:" . implode(' ', $_SERVER['argv']);
        }

        $runtime    = round(microtime(true) - HOPE_START_TIME, 10);
        $reqs       = $runtime > 0 ? number_format(1 / $runtime, 2) : '∞';
        $time_str = ' [运行时间：' . number_format($runtime, 6) . 's] [吞吐率：' . $reqs . 'req/s]';
        $memory_use = number_format((memory_get_usage() - HOPE_START_MEM) / 1024, 2);
        $memory_str = ' [内存消耗：' . $memory_use . 'kb]';
        $file_load  = ' [文件加载：' . count(get_included_files()) . ']';
        $message = '[ info ] [Url：' . $current_uri . ']' . $time_str . $memory_str . $file_load;

        self::record($message);

        $files = File::getFolder($path)['file'];
        if (count($files)) {
            foreach ($files as $file) {
                if ((filemtime($path . $file) + 3600 * 24 * (Config::get('log.time'))) <= time()) {
                    @unlink($path . $file);
                }
            }
        }

        $name = date('Y-m-d') . '.log';
        foreach (self::$log as $value) {
            file_put_contents($path . $name, '[' . date('Y-m-d h:i:s') . '] ' . $value . "\r\n", FILE_APPEND);
        }

        return true;
    }