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


PHP db_merge函数代码示例

本文整理汇总了PHP中db_merge函数的典型用法代码示例。如果您正苦于以下问题:PHP db_merge函数的具体用法?PHP db_merge怎么用?PHP db_merge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     foreach (Element::children($form_state->getValue('stock')) as $sku) {
         $stock = $form_state->getValue(['stock', $sku]);
         db_merge('uc_product_stock')->key(array('sku' => $sku))->updateFields(array('active' => $stock['active'], 'stock' => $stock['stock'], 'threshold' => $stock['threshold']))->insertFields(array('sku' => $sku, 'active' => $stock['active'], 'stock' => $stock['stock'], 'threshold' => $stock['threshold'], 'nid' => $form_state->getValue('nid')))->execute();
     }
     drupal_set_message($this->t('Stock settings saved.'));
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:11,代码来源:StockEditForm.php

示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove Form API elements from $form_state
     $form_state->cleanValues();
     db_merge('uc_attributes')->key(array('aid' => $form_state->getValue('aid')))->fields($form_state->getValues())->execute();
     $form_state->setRedirect('uc_attribute.overview');
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:10,代码来源:AttributeEditForm.php

示例3: write

 public function write($sessionId, $serializedData)
 {
     try {
         // For performance reasons, do not update the sessions table, unless
         // $_SESSION has changed or more than 180 has passed since the last update.
         if ($this->sessionDataHasChanged($sessionId, $serializedData)) {
             // Either ssid or sid or both will be added from $key below.
             $fields = array('uid' => $this->uid, 'cache' => 0, 'hostname' => ip_address(), 'session' => $serializedData, 'timestamp' => REQUEST_TIME);
             $key = array('sid' => $sessionId, 'ssid' => '');
             db_merge('sessions')->key($key)->fields($fields)->execute();
         }
         return TRUE;
     } catch (Exception $exception) {
         // FIXME: This should never be here, a global try/catch should definitely
         // be done upper in the code.
         require_once DRUPAL_ROOT . '/includes/errors.inc';
         // If we are displaying errors, then do so with no possibility of a further
         // uncaught exception being thrown.
         if (error_displayable()) {
             print '<h1>Uncaught exception thrown in session handler.</h1>';
             print '<p>' . _drupal_render_exception_safe($exception) . '</p><hr />';
         }
         return FALSE;
     }
 }
开发者ID:swarad07,项目名称:node_redis,代码行数:25,代码来源:Database.php

示例4: orderSave

 /**
  * {@inheritdoc}
  */
 public function orderSave(OrderInterface $order)
 {
     if (empty($order->payment_details['description'])) {
         db_delete('uc_payment_other')->condition('order_id', $order->id())->execute();
     } else {
         db_merge('uc_payment_other')->key(array('order_id' => $order->id()))->fields(array('description' => $order->payment_details['description']))->execute();
     }
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:11,代码来源:Other.php

示例5: unhandleEntity

 public function unhandleEntity(array $metadata = array())
 {
     if (!empty($metadata['manualcrop_selections']) && is_array($metadata['manualcrop_selections'])) {
         foreach ($metadata['manualcrop_selections'] as $data) {
             db_merge('manualcrop')->key(array('fid' => $this->original_entity->id(), 'style_name' => $data['style_name']))->fields($data)->execute();
         }
     }
 }
开发者ID:sammarks,项目名称:publisher,代码行数:8,代码来源:ManualCropHandler.php

示例6: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Remove Form API elements from $form_state
     $form_state->cleanValues();
     db_merge('uc_attribute_options')->key(array('aid' => $form_state->getValue('aid'), 'oid' => $form_state->getValue('oid')))->fields($form_state->getValues())->execute();
     drupal_set_message($this->t('Updated option %option.', ['%option' => $form_state->getValue('name')]));
     $this->logger('uc_attribute')->notice('Updated option %option.', ['%option' => $form_state->getValue('name'), 'link' => 'admin/store/products/attributes/' . $form_state->getValue('aid') . '/options/' . $form_state->getValue('oid')]);
     $form_state->setRedirect('uc_attribute.options', ['aid' => $form_state->getValue('aid')]);
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:12,代码来源:OptionEditForm.php

示例7: write

 public function write($sid, $value)
 {
     if ($value === '') {
         return true;
     }
     $fields = array('sid' => $sid, 'session' => $value, 'timestamp' => time() + $this->expire);
     db_merge('sessions')->key(array('sid' => $sid))->fields($fields)->execute();
     return true;
 }
开发者ID:royalwang,项目名称:Pyramid,代码行数:9,代码来源:DbSession.php

示例8: putData

 /**
  * Save data associated with a user.
  */
 public function putData($username, $data)
 {
     // Encrypt the data, if a plugin in available.
     if (module_exists('aes')) {
         $data = aes_encrypt($data);
     } elseif (module_exists('encrypt')) {
         $data = encrypt($data);
     }
     $result = db_merge('ga_login')->key(array('name' => $username))->fields(array('keydata' => $data))->execute();
     if ($result) {
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:johnedelatorre,项目名称:fusion,代码行数:18,代码来源:ga_login.class.php

示例9: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $form_state->cleanValues();
     if ($form_state->hasValue('mid')) {
         db_merge('uc_weightquote_methods')->key(array('mid' => $form_state->getValue('mid')))->fields($form_state->getValues())->execute();
         drupal_set_message(t('Weight quote shipping method was updated.'));
         $form_state->setRedirect('uc_quote.methods');
     } else {
         db_insert('uc_weightquote_methods')->fields($form_state->getValues())->execute();
         // Ensure Rules picks up the new condition.
         // entity_flush_caches();
         drupal_set_message(t('Created and enabled new weight quote shipping method.'));
         $form_state->setRedirect('uc_quote.methods');
         //$form_state['redirect'] = 'admin/store/config/quotes/manage/get_quote_from_weightquote_' . $form_state->getValue('mid');
     }
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:19,代码来源:WeightquoteEditForm.php

示例10: set

 /**
  * Implements DrupalCacheInterface::set().
  */
 function set($cid, $data, $expire = CACHE_PERMANENT)
 {
     $fields = array('serialized' => 0, 'created' => REQUEST_TIME, 'expire' => $expire);
     if (!is_string($data)) {
         $fields['data'] = igbinary_serialize($data);
         $fields['serialized'] = 1;
     } else {
         $fields['data'] = $data;
         $fields['serialized'] = 0;
     }
     try {
         db_merge($this->bin)->key(array('cid' => $cid))->fields($fields)->execute();
     } catch (Exception $e) {
         // The database may not be available, so we'll ignore cache_set requests.
     }
 }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:19,代码来源:igbinarycache.php

示例11: import

 /**
  * Run the configured migrations.
  */
 public function import()
 {
     $log = new DrushLogMigrateMessage();
     foreach ($this->migrationList as $migration_id) {
         /** @var MigrationInterface $migration */
         $migration = Migration::load($migration_id);
         drush_print(dt('Upgrading @migration', ['@migration' => $migration_id]));
         $executable = new MigrateExecutable($migration, $log);
         // drush_op() provides --simulate support.
         drush_op([$executable, 'import']);
         // @todo Remove when https://www.drupal.org/node/2598696 is released.
         if ($migration_id == 'd6_user' || $migration_id == 'd7_user') {
             $table = 'migrate_map_' . $migration_id;
             db_merge($table)->key(['sourceid1' => 1])->fields(['destid1' => -1])->execute();
         }
     }
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:20,代码来源:MigrateUpgradeDrushRunner.php

示例12: testGarbageCollection

 /**
  * Tests garbage collection.
  */
 public function testGarbageCollection()
 {
     $collection = $this->randomMachineName();
     $store = new DatabaseStorageExpirable($collection, new PhpSerialize(), Database::getConnection());
     // Insert some items and confirm that they're set.
     for ($i = 0; $i <= 3; $i++) {
         $store->setWithExpire('key_' . $i, $this->randomObject(), rand(500, 100000));
     }
     $this->assertIdentical(sizeof($store->getAll()), 4, 'Four items were written to the storage.');
     // Manually expire the data.
     for ($i = 0; $i <= 3; $i++) {
         db_merge('key_value_expire')->keys(array('name' => 'key_' . $i, 'collection' => $collection))->fields(array('expire' => REQUEST_TIME - 1))->execute();
     }
     // Perform a new set operation and then trigger garbage collection.
     $store->setWithExpire('autumn', 'winter', rand(500, 1000000));
     system_cron();
     // Query the database and confirm that the stale records were deleted.
     $result = db_query('SELECT name, value FROM {key_value_expire} WHERE collection = :collection', array(':collection' => $collection))->fetchAll();
     $this->assertIdentical(count($result), 1, 'Only one item remains after garbage collection');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:23,代码来源:GarbageCollectionTest.php

示例13: menu_save

/**
 * Save a custom menu.
 *
 * @param $menu
 *   An array representing a custom menu:
 *   - menu_name: The unique name of the custom menu (composed of lowercase
 *     letters, numbers, and hyphens).
 *   - title: The human readable menu title.
 *   - description: The custom menu description.
 *
 * Modules should always pass a fully populated $menu when saving a custom
 * menu, so other modules are able to output proper status or watchdog messages.
 *
 * @see menu_load()
 */
function menu_save($menu)
{
    $status = db_merge('menu_custom')->key(array('menu_name' => $menu['menu_name']))->fields(array('title' => $menu['title'], 'description' => $menu['description']))->execute();
    menu_cache_clear_all();
    switch ($status) {
        case SAVED_NEW:
            // Make sure the menu is present in the active menus variable so that its
            // items may appear in the menu active trail.
            // @see menu_set_active_menu_names()
            $active_menus = variable_get('menu_default_active_menus', array_keys(menu_get_menus()));
            if (!in_array($menu['menu_name'], $active_menus)) {
                $active_menus[] = $menu['menu_name'];
                variable_set('menu_default_active_menus', $active_menus);
            }
            module_invoke_all('menu_insert', $menu);
            break;
        case SAVED_UPDATED:
            module_invoke_all('menu_update', $menu);
            break;
    }
}
开发者ID:makinacorpus,项目名称:drupal-usync,代码行数:36,代码来源:polyfill-menu-module.php

示例14: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $changed = FALSE;
     foreach ($form_state->getValue('attributes') as $aid => $attribute) {
         if ($attribute['remove']) {
             $remove_aids[] = $aid;
         } else {
             unset($attribute['remove']);
             db_merge($this->attributeTable)->key('aid', $aid)->fields($attribute)->execute();
             $changed = TRUE;
         }
     }
     if (isset($remove_aids)) {
         $select = db_select('uc_attribute_options', 'ao')->fields('ao', array('oid'))->condition('ao.aid', $remove_aids, 'IN');
         db_delete($this->optionTable)->condition('oid', $select, 'IN')->condition($this->idField, $this->idValue)->execute();
         db_delete($this->attributeTable)->condition($this->idField, $this->idValue)->condition('aid', $remove_aids, 'IN')->execute();
         $this->attributesRemoved();
         drupal_set_message($this->formatPlural(count($remove_aids), '1 attribute has been removed.', '@count attributes have been removed.'));
     }
     if ($changed) {
         drupal_set_message($this->t('The changes have been saved.'));
     }
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:26,代码来源:ObjectAttributesFormBase.php

示例15: assignUser

 /**
  * {@inheritdoc}
  */
 public function assignUser(GradeScaleInterface $grade_scale, $account)
 {
     db_merge('grade_scale_users')->key('uid', $account->id())->fields(array('set_name' => $grade_scale->id()))->execute();
     drupal_static_reset('grade_scale_current_displayed_set');
 }
开发者ID:dakala,项目名称:gradebook,代码行数:8,代码来源:GradeScaleStorage.php


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