修改权限数据(版本兼容暂时保留建议使用createPermission方法)
@param array $data
@param null $id
@return Permission
@throws Exception
329671
public function editPermission(array $data = [], $id = null)
    {
        if (!empty($id)) {
            $data['id'] = $id;
        }
        try{
            return $this->createPermission($data);
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }
1139421
public function saveById($id, $data)
    {
        $exists = !is_null($id);
        if (!$exists) {
            $id = $this->findAvailableIdByData($data);
        }
        parent::saveById($id, $data);
        return $id;
    }
1227576
public function create(array $data)
    {
        $perm = $this->model->create(array(
            'name'        => $data['name'],
            'permissions' => $data['permissions']
        ));

        if ( ! $perm )
        {
            return false;
        }
        else
        {
            $this->event->fire('permissions.create', array($perm));
            return $perm;
        }
    }
1171899
public function update($id, $data)
    {

        $model = $this->findRecord($id);

        $model->update($data);

        return $model;

    }
272368
public function save($data, $id)
    {
        try
        {
            if($this->automaticSerialization)
            {
                $data = serialize($data);
            }
            
            return $this->adapter->setItem($id, $data);
        }
        catch(\Zend\Cache\Exception\ExceptionInterface $e)
        {
            $this->wrapLowLevelException($e, __METHOD__);
        }
    }
143714
public function saveById($id, $data)
    {
        $this->getRequest()->putContents($this->getKey(), $id, $data);
        return $id;
    }
810427
public function update($id, array $data)
    {
        $model = $this->model->find($id);
        $model->fill($data);
        $model->save();

        return $model;
    }
522022
public function update($id, $data)
    {
        $message = $this->client->put(
            sprintf('buckets/%d/messages/%d.json', $this->bucket, $id),
            [
                'json' => $data,
            ]
        );

        return new Message($this->response($message));
    }
179418
public function savePermission($data = [])
    {
        if (!empty($data)) {
            $this->data($data);
        }
        $validate = new \gmars\rbac\validate\Permission();
        if (!$validate->check($this)) {
            throw new Exception($validate->getError());
        }
        $data = $this->getData();
        if (isset($data['id']) && !empty($data['id'])) {
            $this->isUpdate(true);
        }
        $this->save();
        return $this;
    }
102745
protected function insertById($id, $data)
    {
        $fieldList = array_keys($data);
        $SQL = array(
            'INSERT INTO ' . $this->table,
            '(`' . implode('`, `', $fieldList) . '`) VALUES',
            '(:' . implode(', :', $fieldList) . ');'
        );
        $this->execute($SQL, $this->getBindParams($id, $data));
        return $SQL->getLastInsertId();
    }
471009
public function tokenCreate($id, $token = null, $data = null){
		return $this->object->tokenCreate($id, $token, $data);
	}
926457
public function add(string $id, array $data = []): bool
    {
        try {
            $this->setFile($id);
            if ($this->file) {

                if (!file_exists($this->file)) {
                    //Novo
                    if($this->versionamento) {
                        $data['created'] = strtotime("now");
                        $data['updated'] = strtotime("now");
                        parent::deleteVerion($this->file);
                    }

                    $f = fopen($this->file, "w+");
                    fwrite($f, json_encode($data));
                    fclose($f);

                    return true;
                }
            }
            return false;
        } catch (\Exception $e) {
            return false;
        }
    }
392232
public function create($data, $credentialId = null)
    {
        if (isset($credentialId)) {
            return $this->client()->put($data, 'credentials/{credentialId}', ['credentialId' => $credentialId]);
        }

        return $this->client()->post($data, 'credentials');
    }
689419
protected function checkLockVersion($id,&$data) {
        // 检查乐观锁
        $identify   = $this->name.'_'.$id.'_lock_version';
        if($this->optimLock && isset($_SESSION[$identify])) {
            $lock_version = $_SESSION[$identify];
            $vo   =  $this->field($this->optimLock)->find($id);
            $_SESSION[$identify]     =   $lock_version;
            $curr_version = $vo[$this->optimLock];
            if(isset($curr_version)) {
                if($curr_version>0 && $lock_version != $curr_version) {
                    // 记录已经更新
                    $this->error = L('_RECORD_HAS_UPDATE_');
                    return false;
                }else{
                    // 更新乐观锁
                    $save_version = $data[$this->optimLock];
                    if($save_version != $lock_version+1) {
                        $data[$this->optimLock]  =   $lock_version+1;
                    }
                    $_SESSION[$identify]     =   $lock_version+1;
                }
            }
        }
        return true;
    }
95154
public function rowSave($id, $data)
    {
        if (!$data || !is_array($data)) return false;

        if (is_null($id)) {
            $row = $this->getModel()->createRow();
        } else {
            $row = $this->getModel()->getRow($id);
        }

        if (!$row) return false;

        foreach ($data as $col => $value) {
            $row->$col = $value;
        }
        $row->save();

        if ($this->_columns) {
            $ret = array();
            foreach ($this->_columns as $c) {
                $ret[$c] = $row->$c;
            }
            return $ret;
        } else {
            return $row->toArray();
        }
    }
555385
public function update($id, array $data)
    {
        $todo = $this->client->put(
            sprintf('buckets/%d/todos/%d.json', $this->bucket, $id),
            [
                'json' => $data,
            ]
        );

        return new Todo($this->response($todo));
    }
602682
public static function createOrNull($data = null)
    {
        static $request;
        if (!$request) {
            $request = Di::getDefault()->getShared('request');
        }

        if (!$request->isPost()) {
            return null;
        }

        $instance = new static();

        $_request = $request->get();

        if ($data === null || !isset($data[0])) {
            foreach ($instance->getSafeFields() as $field) {
                if (isset($_request[$field])) {
                    $instance->$field = $_request[$field];
                }
            }
        }

        if ($data) {
            foreach ($data as $k => $v) {
                if (is_int($k)) {
                    $field = $v;
                    if (!isset($_request[$field])) {
                        throw new MissingFieldException($field);
                    }
                    $instance->$field = $_request[$field];
                } else {
                    $instance->$k = $v;
                }
            }
        }

        return $instance->create();
    }