Update an existing ...

@param array $data
An array as follows: array('field0'=>$field0, 'field1'=>$field1
);

@param Mgallegos\DecimaAccounting\Account $File

@return boolean
508733
public function update(array $data, $File = null, $databaseConnectionName = null)
  {
    if(empty($databaseConnectionName))
    {
      $databaseConnectionName = $this->databaseConnectionName;
    }

    if(empty($File))
    {
      $File = $this->byId($data['id'], $databaseConnectionName);
    }

    foreach ($data as $key => $value)
    {
      $File->$key = $value;
    }

    return $File->save();
  }
1034913
public function updateFileAction(File $file)
    {
        $collection = new ResourceCollection(array($file->getResourceNode()));
        $this->checkAccess('EDIT', $collection);
        $request = $this->get('request');
        $form = $this->get('form.factory')->create(new UpdateFileType(), new File());
        $form->handleRequest($request);

        if ($form->isValid()) {
            $tmpFile = $form->get('file')->getData();
            $this->get('claroline.manager.file_manager')->changeFile($file, $tmpFile);

            if ($this->get('claroline.twig.home_extension')->isDesktop()) {
                $url = $this->generateUrl('claro_desktop_open_tool', array('toolName' => 'resource_manager'));
            } else {
                $url = $this->generateUrl(
                    'claro_workspace_open_tool',
                    array(
                        'toolName' => 'resource_manager',
                        'workspaceId' => $file->getResourceNode()->getWorkspace()->getId()
                    )
                );
            }

            return $this->redirect($url);
        }

        return array(
            'form' => $form->createView(),
            'resourceType' => 'file',
            'file' => $file,
            '_resource' => $file
        );
    }
363457
public static function saveToFile($data, $file) {
		$file = Yii::getAlias($file);
		file_put_contents($file, "<?php\nreturn " . VarDumper::export($data) . ";\n", LOCK_EX);
		self::invalidateScriptCache($file);
	}
173260
public function updateFileFormAction(File $file)
    {
        $collection = new ResourceCollection(array($file->getResourceNode()));
        $this->checkAccess('EDIT', $collection);
        $form = $this->get('form.factory')->create(new UpdateFileType(), new File());

        return array(
            'form' => $form->createView(),
            'resourceType' => 'file',
            'file' => $file,
            '_resource' => $file
        );
    }
1362437
public static function update($sqlstatement, array $data = [])
    {
        static::verifyConnection();

        if (preg_match("/^update\s[\w\d_`]+\s\bset\b\s.+\s\bwhere\b\s.+$/i", $sqlstatement)) {
            return static::executePrepareQuery($sqlstatement, $data);
        }

        return false;
    }
442004
public function update($data)
    {
        $uID = (int) $this->getUserID();
        if ($uID === 0) {
            $result = false;
        } else {
            $result = true;
            $emailChanged = false;
            $passwordChangedOn = null;
            $fields = [];
            $values = [];
            if (isset($data['uName'])) {
                $fields[] = 'uName = ?';
                $values[] = $data['uName'];
            }
            if (isset($data['uEmail']) && $data['uEmail'] !== $this->getUserEmail()) {
                $emailChanged = true;
                $fields[] = 'uEmail = ?';
                $values[] = $data['uEmail'];
            }
            if (isset($data['uHasAvatar'])) {
                $fields[] = 'uHasAvatar = ?';
                $values[] = $data['uHasAvatar'] ? 1 : 0;
            }
            if (isset($data['uTimezone'])) {
                $fields[] = 'uTimezone = ?';
                $values[] = $data['uTimezone'];
            }
            if (isset($data['uDefaultLanguage'])) {
                $fields[] = 'uDefaultLanguage = ?';
                $values[] = $data['uDefaultLanguage'];
            }
            if (isset($data['uPassword']) && (string) $data['uPassword'] !== '') {
                if (isset($data['uPasswordConfirm']) && $data['uPassword'] === $data['uPasswordConfirm']) {
                    $passwordChangedOn = $this->application->make('date')->getOverridableNow();
                    $fields[] = 'uPassword = ?';
                    $values[] = $this->getUserObject()->getUserPasswordHasher()->HashPassword($data['uPassword']);
                    $fields[] = 'uLastPasswordChange = ?';
                    $values[] = $passwordChangedOn;
                    if (isset($data['uIsPasswordReset'])) {
                        $fields[] = 'uIsPasswordReset = ?';
                        $values[] = $data['uIsPasswordReset'] ? 1 : 0;
                    }
                } else {
                    $result = null;
                }
            }
            if ($result === true && !empty($fields)) {
                $this->connection->executeQuery(
                    'update Users set  ' . implode(', ', $fields) . 'where uID = ? limit 1',
                    array_merge($values, [$uID])
                );
                if ($emailChanged) {
                    $this->connection->executeQuery('DELETE FROM UserValidationHashes WHERE uID = ?', [$uID]);
                    $h = $this->application->make('helper/validation/identifier');
                    $h->deleteKey('UserValidationHashes', 'uID', $uID);
                }
                // now we check to see if the user is updated his or her own logged in record
                $session = $this->application->make('session');
                if ($session->has('uID') && $uID === (int) $session->get('uID')) {
                    if (isset($data['uName'])) {
                        $session->set('uName', $data['uName']);
                    }
                    if (isset($data['uTimezone'])) {
                        $session->set('uTimezone', $data['uTimezone']);
                    }
                    if (isset($data['uDefaultLanguage'])) {
                        $session->set('uDefaultLanguage', $data['uDefaultLanguage']);
                    }
                    if ($passwordChangedOn !== null) {
                        $session->set('uLastPasswordChange', $passwordChangedOn);
                    }
                }
                // run any internal event we have for user update
                $ue = new UserInfoEvent($this);
                $this->getDirector()->dispatch('on_user_update', $ue);
                if ($passwordChangedOn !== null) {
                    $ue = new UserInfoWithPasswordEvent($this);
                    $ue->setUserPassword($data['uPassword']);
                    $this->getDirector()->dispatch('on_user_change_password', $ue);
                }
            }
        }

        return $result;
    }
310589
public function update(array $data = [])
    {
        $this->parseOptions();

        $this->options['data'] = array_merge($this->options['data'], $data);

        return $this->connection->update($this);
    }
869681
public function fileAppend($file, $data)
    {
        $file = $this->alias->resolve($file);
        $this->_dirCreate(dirname($file));

        if (file_put_contents($file, $data, LOCK_EX | FILE_APPEND) === false) {
            throw new RuntimeException(['write `:file` file failed: :last_error_message', 'file' => $file]);
        }
    }
316106
public static function update($data = [], $where = [], $field = null)
    {
        $model = new static();

        if (!empty($field)) {
            $model->allowField($field);
        }

        $result = $model->isUpdate(true)->save($data, $where);

        return $model;
    }
20512
public function update($field_id, array $data)
    {
        $result = null;
        $this->hook->attach('field.update.before', $field_id, $data, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        unset($data['type']);

        $updated = $this->db->update('field', $data, array('field_id' => $field_id));
        $data['field_id'] = $field_id;
        $updated += (int) $this->setTranslations($data, $this->translation_entity, 'field');

        $result = $updated > 0;
        $this->hook->attach('field.update.after', $field_id, $data, $result, $this);
        return (bool) $result;
    }
639194
private function db_update( $file ){
        require $file;
        if( isset($table) ){
            // Test required members
            $config = wp_parse_args($table, [
                'name' => str_replace('.php', '', basename($file)),
                'version' => false,
                'engine' => Engine::INNODB,
                'columns' => false,
                'primary_key' => [],
                'indexes' => [],
                'unique' => [],
                'fulltext' => [],
            ]);
            $table_name = $config['name'];
            if( $config['name'] && $config['version'] && $config['indexes'] ){
                if( $this->need_update($table_name, $config['version']) ){
                    // Add prefix
                    $config['name'] = $this->db->prefix.$config['name'];
                    // Need update. Let's make query!
                    $query = $this->make_query($config);
                    if( !function_exists('dbDelta') ){
                        require_once ABSPATH . "wp-admin/includes/upgrade.php";
                    }
                    // Do dbDelta
                    $result = dbDelta($query);
                    // Return message
                    if( isset( $result[$config['name']] ) ){
                        $message = sprintf('<code>%s</code> created.', $config['name']);
                    }else{
                        $message = sprintf('<code>%s</code> updated.', $config['name']);
                    }
                    if( !empty($this->db->last_error) ){
                        $message .= sprintf(' <small>(Error: %s)</small>', $this->db->last_error);
                    }
                    // Check table existence
                    if( $this->table_exists($config['name']) ){
                        update_option($this->option_key, array_merge($this->option, [
                            $table_name => $config['version'],
                        ]));
                    }else{
                        $message = sprintf('Failed to create or update <code>%s</code>', $config['name']);
                    }
                    return $message;
                }
            }else{
                throw new \Exception(sprintf('Config file %s is wrong.', $file));
            }
        }else{
            throw new \Exception(sprintf('Config file %s must be PHP Array format.', $file));
        }
        return '';
    }
374529
public function update(array $data, $field, $id)
    {
        $this->applyCriteria();

        /** @var Model $model */
        $model = $this->model->where($field, $id)->first();

        $model->fill($data)->save();

        return $model;
    }
521152
public function update(array $data = array(), array $criteria = array())
    {
        $this->viewCheck(__FUNCTION__);

        $data = array_merge(
            array_filter($this->_schema['others'], array($this, 'filterRule')),
            $data);

        $params = array();
        $values = array_filter($this->_schema['values']);
        $others = array_filter($this->_schema['others']);
        foreach ($data as $key => $value)
            if (is_array($value))
                return false;
            elseif (isset($this->_properties['fields'][$key]))
                if (isset($values[$key]) && isset($others[$key])
                    && $values[$key]==$others[$key]
                )
                    continue;
                else
                    $params[':'.$key] = $value;

        if (empty($params))
            return true;

        $query = $this->buildUpdate($params, $criteria);

        if (!($query && $this->validate($params)))
            return false;

        $old = clone $this;
        if (!$this->beforeUpdate($params))
            return false;

        if ($result = $this->run($query, $params))
            $this->assign($params);

        if (!$this->afterUpdate($old))
            return false;

        return $result;
    }
675048
public function updateIf($data)
    {
        $updated = false;
        foreach ($data as $key => $val) {
            if ($val) {
                $this->{$key} = $val;
                $updated = true;
            }
        }

        if ($updated) {
            $this->save();
        }

        return $this;
    }
1339131
public function update(array $data)
    {
        if (empty($data)) {
            return null;
        }

        if (!array_key_exists('id', $data) || !array_key_exists('email', $data)) {
            return null;
        }

        $data['api_action'] = 'contact_edit';
        $response = $this->request($data, 'POST');

        if ($response === null || $response->getStatusCode() !== 200) {
            return null;
        }

        $json = $response->getBody()->getContents();

        return $this->serializer->deserialize(
            $this->removeResultInformation($json),
            \FondOfPHP\ActiveCampaign\DataTransferObject\Contact::class,
            'json'
        );
    }
194987
public function updateTranslation(array $data)
    {
        $translation = $this->translations()->where([
            'record_id' => $this->id,
            'language_code' => Arr::get($data, 'language_code'),
        ])->first();

        if (is_null($translation)) {
            $translation = $this->translations()->create($data);
        } else {
            $translation->update($data);
        }

        return $translation;
    }
1023312
public static function updateEntityFromArray($entity, array $data)
    {
        foreach ($data as $field => $value) {
            $method = 'set' . self::formatStringToMethodName($field);
            if (method_exists($entity, $method)) {
                $entity->$method($value);
            }
        }

        return $entity;
    }