当前位置: 首页>>代码示例>>PHP>>正文


PHP DBManager::update方法代码示例

本文整理汇总了PHP中DBManager::update方法的典型用法代码示例。如果您正苦于以下问题:PHP DBManager::update方法的具体用法?PHP DBManager::update怎么用?PHP DBManager::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBManager的用法示例。


在下文中一共展示了DBManager::update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testUpdate

 public function testUpdate()
 {
     $bean = new Contact();
     $bean->last_name = 'foobar' . mt_rand();
     $bean->id = 'test' . mt_rand();
     $this->_db->insert($bean);
     $id = $bean->id;
     $bean = new Contact();
     $bean->last_name = 'newfoobar' . mt_rand();
     $this->_db->update($bean, array('id' => $id));
     $result = $this->_db->query("select id, last_name from contacts where id = '{$id}'");
     $row = $this->_db->fetchByAssoc($result);
     $this->assertEquals($row['last_name'], $bean->last_name);
     $this->assertEquals($row['id'], $id);
     $this->_db->query("delete from contacts where id = '{$row['id']}'");
 }
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:16,代码来源:DBManagerTest.php

示例2: save

 /**
  * Implements a generic insert and update logic for any SugarBean
  * This method only works for subclasses that implement the same variable names.
  * This method uses the presence of an id field that is not null to signify and update.
  * The id field should not be set otherwise.
  *
  * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email.
  * @todo Add support for field type validation and encoding of parameters.
  */
 function save($check_notify = FALSE)
 {
     $this->in_save = true;
     // cn: SECURITY - strip XSS potential vectors
     $this->cleanBean();
     // This is used so custom/3rd-party code can be upgraded with fewer issues, this will be removed in a future release
     $this->fixUpFormatting();
     global $timedate;
     global $current_user, $action;
     $isUpdate = true;
     if (empty($this->id)) {
         $isUpdate = false;
     }
     if ($this->new_with_id == true) {
         $isUpdate = false;
     }
     if (empty($this->date_modified) || $this->update_date_modified) {
         $this->date_modified = $GLOBALS['timedate']->nowDb();
     }
     $this->_checkOptimisticLocking($action, $isUpdate);
     if (!empty($this->modified_by_name)) {
         $this->old_modified_by_name = $this->modified_by_name;
     }
     if ($this->update_modified_by) {
         $this->modified_user_id = 1;
         if (!empty($current_user)) {
             $this->modified_user_id = $current_user->id;
             $this->modified_by_name = $current_user->user_name;
         }
     }
     if ($this->deleted != 1) {
         $this->deleted = 0;
     }
     if (!$isUpdate) {
         if (empty($this->date_entered)) {
             $this->date_entered = $this->date_modified;
         }
         if ($this->set_created_by == true) {
             // created by should always be this user
             $this->created_by = isset($current_user) ? $current_user->id : "";
         }
         if ($this->new_with_id == false) {
             $this->id = create_guid();
         }
     }
     require_once "data/BeanFactory.php";
     BeanFactory::registerBean($this->module_name, $this);
     if (empty($GLOBALS['updating_relationships']) && empty($GLOBALS['saving_relationships']) && empty($GLOBALS['resavingRelatedBeans'])) {
         $GLOBALS['saving_relationships'] = true;
         // let subclasses save related field changes
         $this->save_relationship_changes($isUpdate);
         $GLOBALS['saving_relationships'] = false;
     }
     if ($isUpdate && !$this->update_date_entered) {
         unset($this->date_entered);
     }
     // call the custom business logic
     $custom_logic_arguments['check_notify'] = $check_notify;
     $this->call_custom_logic("before_save", $custom_logic_arguments);
     unset($custom_logic_arguments);
     // If we're importing back semi-colon separated non-primary emails
     if ($this->hasEmails() && !empty($this->email_addresses_non_primary) && is_array($this->email_addresses_non_primary)) {
         // Add each mail to the account
         foreach ($this->email_addresses_non_primary as $mail) {
             $this->emailAddress->addAddress($mail);
         }
         $this->emailAddress->save($this->id, $this->module_dir);
     }
     if (isset($this->custom_fields)) {
         $this->custom_fields->bean = $this;
         $this->custom_fields->save($isUpdate);
     }
     // use the db independent query generator
     $this->preprocess_fields_on_save();
     //construct the SQL to create the audit record if auditing is enabled.
     $auditDataChanges = array();
     if ($this->is_AuditEnabled()) {
         if ($isUpdate && !isset($this->fetched_row)) {
             $GLOBALS['log']->debug('Auditing: Retrieve was not called, audit record will not be created.');
         } else {
             $auditDataChanges = $this->db->getAuditDataChanges($this);
         }
     }
     $this->_sendNotifications($check_notify);
     if ($isUpdate) {
         $this->db->update($this);
     } else {
         $this->db->insert($this);
     }
     if (!empty($auditDataChanges) && is_array($auditDataChanges)) {
         foreach ($auditDataChanges as $change) {
//.........这里部分代码省略.........
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:101,代码来源:SugarBean.php

示例3: header

    $_SESSION['message'] = ['text' => 'Wählen Sie einen Benutzer aus', 'type' => 'danger'];
    header('Location: ' . LINK_OVERVIEW);
    die;
}
//Prüfen ob Formular abgeschickt wurde
if ($_POST) {
    //Daten von Formular in Array speichern und prüfen
    $userData = getDataFromPost();
    if (!isset($userData['error'])) {
        //Benutzer von Datenbank laden und eingegebenen Daten speichern
        $dbmanager = new DBManager();
        if ($dbmanager->isConnected()) {
            $user = $dbmanager->get('User', $_GET['user']);
            $user->fetchData($userData);
            //die(var_dump($user));
            if ($dbmanager->update('User', [$user])) {
                $_SESSION['message'] = ['type' => 'success', 'text' => 'Das Mitglied wurde im System gespeichert'];
                header('Location: ' . LINK_OVERVIEW);
                die;
            } else {
                $_SESSION['message'] = ['type' => 'danger', 'text' => 'Die Daten konnten nicht gespeichert werde'];
            }
        } else {
            $_SESSION['message'] = ['type' => 'danger', 'text' => 'Es konnte keine Verbindung zur Datenbank hergestellt werden'];
        }
    } else {
        $_SESSION['message'] = ['type' => 'danger', 'text' => $userData['error']];
    }
}
$tmpl = new Templating();
$wrappers = $tmpl->renderWrapper('layoutMenu.html');
开发者ID:kpbl,项目名称:vereinsverwaltung,代码行数:31,代码来源:edit.php

示例4: save

 /**
  * Implements a generic insert and update logic for any SugarBean
  * This method only works for subclasses that implement the same variable names.
  * This method uses the presence of an id field that is not null to signify and update.
  * The id field should not be set otherwise.
  *
  * @param boolean $check_notify Optional, default false, if set to true assignee of the record is notified via email.
  * @todo Add support for field type validation and encoding of parameters.
  */
 function save($check_notify = false)
 {
     $this->in_save = true;
     // cn: SECURITY - strip XSS potential vectors
     $this->cleanBean();
     // This is used so custom/3rd-party code can be upgraded with fewer issues, this will be removed in a future release
     $this->fixUpFormatting();
     global $timedate;
     global $current_user, $action;
     $isUpdate = true;
     if (empty($this->id) || !empty($this->new_with_id)) {
         $isUpdate = false;
     }
     if (empty($this->date_modified) || $this->update_date_modified) {
         $this->date_modified = $GLOBALS['timedate']->nowDb();
     }
     $this->_checkOptimisticLocking($action, $isUpdate);
     if (!empty($this->modified_by_name)) {
         $this->old_modified_by_name = $this->modified_by_name;
     }
     if ($this->update_modified_by) {
         $this->modified_user_id = 1;
         if (!empty($current_user)) {
             $this->modified_user_id = $current_user->id;
             $this->modified_by_name = $current_user->user_name;
         }
     }
     if ($this->deleted != 1) {
         $this->deleted = 0;
     }
     if (!$isUpdate) {
         if (empty($this->date_entered)) {
             $this->date_entered = $this->date_modified;
         }
         if ($this->set_created_by == true) {
             // created by should always be this user
             $this->created_by = isset($current_user) ? $current_user->id : "";
         }
         if ($this->new_with_id == false) {
             $this->id = create_guid();
         }
     }
     // if the module has a team_id field and no team_id is specified, set team_id as the current_user's default team
     // currently, the default_team is only enforced in the presentation layer-- this enforces it at the data layer as well
     $usedDefaultTeam = false;
     if (empty($this->team_id) && isset($this->field_defs['team_id']) && isset($current_user)) {
         $this->team_id = $current_user->team_id;
         $usedDefaultTeam = true;
     }
     // if this bean has a currency_id and base_rate, verify that base_rate is set to the correct amount
     if (isset($this->field_defs['currency_id']) && isset($this->field_defs['base_rate'])) {
         SugarCurrency::verifyCurrencyBaseRateSet($this, $isUpdate);
     }
     require_once "data/BeanFactory.php";
     BeanFactory::registerBean($this);
     if (!static::inOperation('saving_related') && static::enterOperation('updating_relationships')) {
         // let subclasses save related field changes
         $this->save_relationship_changes($isUpdate);
         static::leaveOperation('updating_relationships');
     }
     $this->updateCalculatedFields();
     if ($isUpdate && !$this->update_date_entered) {
         unset($this->date_entered);
     }
     // call the custom business logic
     $custom_logic_arguments = array('check_notify' => $check_notify, 'isUpdate' => $isUpdate);
     $this->call_custom_logic("before_save", $custom_logic_arguments);
     unset($custom_logic_arguments);
     if (isset($this->custom_fields)) {
         $this->custom_fields->bean = $this;
         $this->custom_fields->save($isUpdate);
     }
     //rrs new functionality to check if the team_id is set and the team_set_id is not set,
     //then see what we can do about saving to team_set_id. It is important for this code block to be below
     //the 'before_save' custom logic hook as that is where workflow is called.
     if (isset($this->field_defs['team_id'])) {
         if (empty($this->teams)) {
             $this->load_relationship('teams');
         }
         if (!empty($this->teams)) {
             //we do not need to the TeamSetLink to update the bean's table here
             //since it will be handled below.
             $this->teams->save(false, $usedDefaultTeam);
         }
     }
     // use the db independent query generator
     $this->preprocess_fields_on_save();
     $dataChanges = $this->db->getDataChanges($this);
     //construct the SQL to create the audit record if auditing is enabled.
     $auditDataChanges = array();
     if ($this->is_AuditEnabled()) {
//.........这里部分代码省略.........
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:101,代码来源:SugarBean.php

示例5: DBManager

<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/vereinsverwaltung/src/conf/config.php';
securityCheck();
$dbmanager = new DBManager();
//Eintrag auf 'bezahlt' setzen
if (isset($_GET['payed'])) {
    if (isset($_GET['date']) && !empty($_GET['date'])) {
        $dateObj = date_create_from_format('d.m.Y', $_GET['date']);
        if (dateObj !== FALSE) {
            $accHist = $dbmanager->get('Account_History', $_GET['payed']);
            $accHist->setPayed(true);
            $accHist->setDate_payed($dateObj);
            if ($dbmanager->update('Account_History', [$accHist])) {
                $message = ['type' => 'success', 'text' => 'Der Eintrag wurde als Bezahlt gespeichert'];
            } else {
                $message = ['type' => 'danger', 'text' => 'Der Eintrag konnte nicht bearbeitet werden'];
            }
            $_SESSION['message'] = $message;
            header('location: ' . LINK_MONEY);
        }
        $_SESSION['message'] = ['type' => 'danger', 'text' => 'Das Datum muss im Format d.m.Y sein'];
    }
    $_SESSION['message'] = ['type' => 'danger', 'text' => 'Geben Sie ein Datum an'];
}
//Editierte Kontodaten speichern
if (isset($_POST['account_name'])) {
    $account = $dbmanager->get('Account', $_POST['account_id']);
    $account->setName($_POST['account_name']);
    $account->setIban($_POST['account_iban']);
    $account->setBic($_POST['account_bic']);
开发者ID:kpbl,项目名称:vereinsverwaltung,代码行数:31,代码来源:account.php


注:本文中的DBManager::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。