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


PHP wpdb::update方法代码示例

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


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

示例1: _update

 protected function _update()
 {
     if (($result = $this->_wpdb->update($this->_table(), $this->_fields, array($this->_pk => $this->{$this->_pk}))) === FALSE) {
         echo 'false';
         return FALSE;
     }
     return TRUE;
 }
开发者ID:slavic18,项目名称:cats,代码行数:8,代码来源:fruitframe-db-model.php

示例2: update

 /**
  * Update taxonomy meta
  *
  * @param int $term_id
  * @param string $key
  * @param mixed $value
  * @return int
  */
 public function update($term_id, $key, $value)
 {
     $old_value = $this->get($term_id, $key);
     if ($old_value === false) {
         return $this->_add($term_id, $key, $value);
     }
     if ($old_value === $value) {
         return true;
     }
     wp_cache_set($this->_get_cache_key($term_id, $key), $value, 'taxonomy-meta');
     return $this->_db->update($this->_table, ['meta_value' => maybe_serialize($value)], ['term_id' => $term_id, 'meta_key' => $key]);
 }
开发者ID:jar-laks,项目名称:wpkit,代码行数:20,代码来源:TaxonomyMeta.php

示例3: saveRuleset

 /**
  * Saves a ruleset to database.
  *
  * @param array $rulesetData The data to save.
  * @param int $rulesetId Primary key of ruleset if it already exists.
  * @return bool|int Id of saved rule on success or false on error.
  */
 public function saveRuleset($rulesetData, $rulesetId = 0)
 {
     if (empty($rulesetData)) {
         return false;
     }
     if (!empty($rulesetId)) {
         $updateResult = $this->wpdb->update($this->wpdb->rulesets, $rulesetData, array('id' => $rulesetId), array('%s', '%d', '%s', '%d', '%d', '%s', '%s', '%d', '%s'), array('%d'));
         return $updateResult === false ? false : $rulesetId;
     } else {
         $this->wpdb->insert($this->wpdb->rulesets, $rulesetData, array('%s', '%d', '%s', '%d', '%d', '%s', '%s', '%d', '%s'));
         $rulesetId = $this->wpdb->insert_id;
         return empty($rulesetId) ? false : $rulesetId;
     }
 }
开发者ID:ProjectArmy,项目名称:wp_wemahu,代码行数:21,代码来源:ruleset.php

示例4: move_subscription

 public function move_subscription($fromsub_id, $tosub_id, $tolevel_id, $to_order)
 {
     if (!apply_filters('pre_membership_move_subscription', true, $fromsub_id, $tosub_id, $tolevel_id, $to_order, $this->ID)) {
         return false;
     }
     membership_debug_log(sprintf(__('MEMBER: Moving subscription from %d to %d', 'membership'), $fromsub_id, $tosub_id));
     $factory = Membership_Plugin::factory();
     // Check if existing level matches new one but it is a serial or indefinite level
     $subscription = $factory->get_subscription($tosub_id);
     $nextlevel = $subscription->get_next_level($tolevel_id, $to_order);
     if (!$this->on_level($tolevel_id, true, $to_order) || $this->on_level($tolevel_id, true, $to_order) && ($nextlevel->sub_type == 'serial' || $nextlevel->sub_type == 'indefinite') && $this->on_sub($fromsub_id)) {
         membership_debug_log(sprintf(__('MEMBER: New level to move to %d on order %d', 'membership'), $tolevel_id, $to_order));
         // Get the level for this subscription before removing it
         $fromlevel_id = $this->get_level_for_sub($fromsub_id);
         // grab the level information for this position
         $subscription = $factory->get_subscription($tosub_id);
         $level = $subscription->get_level_at($tolevel_id, $to_order);
         if ($level) {
             $period = 'days';
             $now = current_time('mysql');
             $start = strtotime($now);
             switch ($level->level_period_unit) {
                 case 'd':
                     $period = 'days';
                     break;
                 case 'w':
                     $period = 'weeks';
                     break;
                 case 'm':
                     $period = 'months';
                     break;
                 case 'y':
                     $period = 'years';
                     break;
             }
             //subscription start and end date
             $start_sub = $tosub_id == $fromsub_id ? get_user_meta($this->ID, 'start_current_' . $fromsub_id, true) : $start;
             $expires_sub = $this->get_subscription_expire_date($subscription, $tolevel_id, $fromsub_id, $fromlevel_id);
             //level end date
             $expires = gmdate('Y-m-d H:i:s', strtotime('+' . $level->level_period . ' ' . $period, $start));
             // Update users start and expiry meta
             delete_user_meta($this->ID, 'start_current_' . $fromsub_id);
             delete_user_meta($this->ID, 'expire_current_' . $fromsub_id);
             delete_user_meta($this->ID, 'sent_msgs_' . $fromsub_id);
             // get the gateway and then remove it from the usermeta
             $gateway = get_user_meta($this->ID, 'using_gateway_' . $fromsub_id, true);
             delete_user_meta($this->ID, 'using_gateway_' . $fromsub_id);
             update_user_meta($this->ID, 'start_current_' . $tosub_id, $start_sub);
             update_user_meta($this->ID, 'expire_current_' . $tosub_id, $expires_sub);
             update_user_meta($this->ID, 'using_gateway_' . $tosub_id, $gateway);
             $this->_wpdb->update(MEMBERSHIP_TABLE_RELATIONS, array('sub_id' => $tosub_id, 'level_id' => $tolevel_id, 'updateddate' => $now, 'expirydate' => $expires, 'order_instance' => $level->level_order), array('sub_id' => $fromsub_id, 'user_id' => $this->ID));
             // Update the associated role
             $this->set_role(Membership_Model_Level::get_associated_role($level->level_id));
             membership_debug_log(sprintf(__('MEMBER: Completed move to %d on order %d on sub %d', 'membership'), $tolevel_id, $to_order, $tosub_id));
             do_action('membership_move_subscription', $fromsub_id, $fromlevel_id, $tosub_id, $tolevel_id, $to_order, $this->ID);
         }
     } else {
         membership_debug_log(sprintf(__('MEMBER: Already on level %d on order %d', 'membership'), $tolevel_id, $to_order));
     }
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:60,代码来源:Member.php

示例5: update_form

 /**
  * Update the data for a particular form.
  *
  * @author Jeremy Pry
  *
  * @param int   $form_id The form ID to update.
  * @param array $data    The form data to update.
  *
  * @return bool Whether the form was successfully updated.
  */
 public function update_form($form_id, $data)
 {
     // Prepare the data for the database.
     $data['id'] = $form_id;
     $save_data = $this->prepare_data_for_db($data);
     $formats = $this->get_format_array($save_data);
     return (bool) $this->wpdb->update($this->prefixed_table_name, $save_data, array('id' => $form_id), $formats, '%d');
 }
开发者ID:yikesinc,项目名称:yikes-inc-easy-mailchimp-extender,代码行数:18,代码来源:class-yikes-inc-easy-mailchimp-extender-forms.php

示例6: _record_transaction

 /**
  * Records transaction into database.
  *
  * @access protected
  * @param type $user_id
  * @param type $sub_id
  * @param type $amount
  * @param type $currency
  * @param type $timestamp
  * @param type $paypal_ID
  * @param type $status
  * @param type $note
  */
 protected function _record_transaction($user_id, $sub_id, $amount, $currency, $timestamp, $paypal_ID, $status, $note)
 {
     $data = array('transaction_subscription_ID' => $sub_id, 'transaction_user_ID' => $user_id, 'transaction_paypal_ID' => $paypal_ID, 'transaction_stamp' => $timestamp, 'transaction_currency' => $currency, 'transaction_status' => $status, 'transaction_total_amount' => (int) round($amount * 100), 'transaction_note' => $note, 'transaction_gateway' => $this->gateway);
     $existing_id = $this->db->get_var($this->db->prepare("SELECT transaction_ID FROM " . MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION . " WHERE transaction_paypal_ID = %s LIMIT 1", $paypal_ID));
     if (!empty($existing_id)) {
         $this->db->update(MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION, $data, array('transaction_ID' => $existing_id));
     } else {
         $this->db->insert(MEMBERSHIP_TABLE_SUBSCRIPTION_TRANSACTION, $data);
     }
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:23,代码来源:Gateway.php

示例7: update

 function update()
 {
     $this->dirty = true;
     if ($this->id < 0) {
         $this->add();
     } else {
         $this->db->update(MEMBERSHIP_TABLE_SUBSCRIPTIONS, array('sub_name' => trim(filter_input(INPUT_POST, 'sub_name')), 'sub_description' => trim(filter_input(INPUT_POST, 'sub_description')), 'sub_pricetext' => trim(filter_input(INPUT_POST, 'sub_pricetext')), 'order_num' => filter_input(INPUT_POST, 'sub_order_num', FILTER_VALIDATE_INT)), array('id' => $this->id), array('%s', '%s', '%s', '%d'), array('%d'));
         // Remove the existing rules for this subscription level
         $this->db->delete(MEMBERSHIP_TABLE_SUBSCRIPTION_LEVELS, array('sub_id' => $this->id), array('%d'));
         if (!empty($_POST['level-order'])) {
             $levels = explode(',', $_POST['level-order']);
             $count = 1;
             foreach ((array) $levels as $level) {
                 if (!empty($level)) {
                     // Check if the rule has any information for it.
                     if (isset($_POST['levelmode'][$level])) {
                         $levelmode = esc_attr($_POST['levelmode'][$level]);
                     } else {
                         continue;
                     }
                     if (isset($_POST['levelperiod'][$level])) {
                         $levelperiod = esc_attr($_POST['levelperiod'][$level]);
                     } else {
                         $levelperiod = '';
                     }
                     if (isset($_POST['levelperiodunit'][$level])) {
                         $levelperiodunit = esc_attr($_POST['levelperiodunit'][$level]);
                     } else {
                         $levelperiodunit = '';
                     }
                     if (isset($_POST['levelprice'][$level])) {
                         $levelprice = floatval(esc_attr($_POST['levelprice'][$level]));
                     } else {
                         $levelprice = '';
                     }
                     if (isset($_POST['levelcurrency'][$level])) {
                         $levelcurrency = esc_attr($_POST['levelcurrency'][$level]);
                     } else {
                         $levelcurrency = '';
                     }
                     // Calculate the level id
                     $lev = explode('-', $level);
                     if ($lev[0] == 'level') {
                         $level_id = (int) $lev[1];
                         // write it to the database
                         $this->db->insert(MEMBERSHIP_TABLE_SUBSCRIPTION_LEVELS, array("sub_id" => $this->id, "level_period" => $levelperiod, "sub_type" => $levelmode, "level_price" => $levelprice, "level_currency" => $levelcurrency, "level_order" => $count++, "level_id" => $level_id, "level_period_unit" => $levelperiodunit));
                     }
                 }
             }
         }
         do_action('membership_subscription_update', $this->id);
     }
     return true;
     // for now
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:55,代码来源:Subscription.php

示例8: attach_uploads

 /**
  * Attach upload to a post.
  *
  * @since 2.1.0
  *
  * @param int $post_ID Post ID.
  * @param string $post_content Post Content for attachment.
  */
 public function attach_uploads($post_ID, $post_content)
 {
     // find any unattached files
     $attachments = $this->db->get_results("SELECT ID, guid FROM {$this->db->posts} WHERE post_parent = '0' AND post_type = 'attachment'");
     if (is_array($attachments)) {
         foreach ($attachments as $file) {
             if (!empty($file->guid) && strpos($post_content, $file->guid) !== false) {
                 $this->db->update($this->db->posts, array('post_parent' => $post_ID), array('ID' => $file->ID));
             }
         }
     }
 }
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:20,代码来源:class-wp-xmlrpc-server.php

示例9: upgrade_forms

 /**
  * Upgrades all the existing forms in the database to include the new fields and settings offered by the latest plugin version.
  *
  * @param array $default_fields An array containing the default form fields and their settings.
  * @param array $default_settings An array containing the default form settings.
  * @param array $default_emails An array containing the default emails.
  * @param array $default_custom_field An array containing the default custom field settings.
  * @param array $post_type The post type for which we want to upgrade the forms.
  **/
 public function upgrade_forms($default_fields, $default_settings, $default_emails, $default_custom_field, $post_type)
 {
     $forms = $this->get_forms(1, 1000, $post_type);
     if (is_array($forms) && count($forms)) {
         foreach ($forms as $key => $form) {
             $form_fields = $this->unserialize($form['fields']);
             $form_settings = $this->unserialize($form['settings']);
             $form_emails = $this->unserialize($form['emails']);
             $upgraded_fields = wpfepp_update_form_fields($form_fields, $default_fields, $default_custom_field);
             $upgraded_settings = wpfepp_update_array($form_settings, $default_settings);
             $upgraded_emails = wpfepp_update_array($form_emails, $default_emails);
             $this->db->update($this->table_name, array('fields' => $this->serialize($upgraded_fields), 'settings' => $this->serialize($upgraded_settings), 'emails' => $this->serialize($upgraded_emails)), array('id' => $form['id']));
         }
     }
 }
开发者ID:poweronio,项目名称:mbsite,代码行数:24,代码来源:class-wpfepp-db-table.php

示例10: update

 function update()
 {
     switch ($_POST['periodtype']) {
         case 'd':
             $time = strtotime('+' . $_POST['periodunit'] . ' days') - time();
             break;
         case 'm':
             $time = strtotime('+' . $_POST['periodunit'] . ' months') - time();
             break;
         case 'y':
             $time = strtotime('+' . $_POST['periodunit'] . ' years') - time();
             break;
     }
     $periodstamp = $_POST['periodprepost'] == 'pre' ? -$time : $time;
     if ('join' == $_POST['periodprepost'] || 'exp' == $_POST['periodprepost']) {
         $periodstamp = 0;
     }
     $updates = array("periodunit" => $_POST['periodunit'], "periodtype" => $_POST['periodtype'], "periodprepost" => $_POST['periodprepost'], "subject" => $_POST['subject'], "message" => stripslashes($_POST['message']), "periodstamp" => $periodstamp, "sub_id" => $_POST['subscription_id']);
     return $this->db->update(MEMBERSHIP_TABLE_COMMUNICATIONS, $updates, array("id" => $this->id));
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:20,代码来源:class.communication.php

示例11: save

 /**
  * Saves data into the database.
  *
  * @since 2.0.0
  *
  * @param array $data The data to insert into database.
  *
  * @return bool
  * @throws Exception
  */
 public function save($data)
 {
     $time = current_time('mysql');
     // Only save leads if the user has the option checked.
     $option = get_option('optin_monster');
     if (!isset($option['leads']) || isset($option['leads']) && !$option['leads']) {
         throw new Exception(__('The user has chosen not to store leads locally.', 'optin-monster'));
     }
     // Make sure the required fieds exist in the passed data array.
     foreach ($this->required_fields as $key => $value) {
         if (!array_key_exists($value, $data)) {
             throw new Exception(sprintf(__('A value for %s must be passed in the $data array.', 'optin-monster'), $value));
         }
     }
     // Ensure that the lead does not already exist in the DB.
     $exists = $this->find_where('lead_email', $data['lead_email']);
     if (!empty($exists)) {
         throw new Exception(__('The lead already exists in the database.', 'optin-monster'));
     }
     // Add the date modified to the data array
     $data['date_modified'] = $time;
     // If an 'id' is passed, we're going to update the record, else insert.
     if (isset($data['id'])) {
         $id = $data['id'];
         unset($data['id']);
         if (false == $this->db->update($this->table, $data, array('lead_id', $id))) {
             throw new Exception(__('There was an error updating the lead.', 'optin-monster'));
         } else {
             return true;
         }
     } else {
         // This is a new record, so we'll insert the date added.
         $data['date_added'] = $time;
         if (false == $this->db->insert($this->table, $data)) {
             throw new Exception(__('There was an error inserting the lead.', 'optin-monster'));
         } else {
             return true;
         }
     }
 }
开发者ID:venturepact,项目名称:blog,代码行数:50,代码来源:lead-datastore.php

示例12: import_active_languages

 /**
  * Load the localization
  *
  * @since 0.1
  * @uses load_plugin_textdomain, plugin_basename
  * @param Mlp_Db_Schema_Interface $languages
  * @return void
  */
 private function import_active_languages(Mlp_Db_Schema_Interface $languages)
 {
     // get active languages
     $mlp_settings = get_site_option('inpsyde_multilingual');
     if (empty($mlp_settings)) {
         return;
     }
     $table = $languages->get_table_name();
     $sql = 'SELECT ID FROM ' . $table . 'WHERE wp_locale = %s OR iso_639_1 = %s';
     foreach ($mlp_settings as $mlp_site) {
         $text = $mlp_site['text'] != '' ? $mlp_site['text'] : $mlp_site['lang'];
         $query = $this->wpdb->prepare($sql, $mlp_site['lang'], $mlp_site['lang']);
         $lang_id = $this->wpdb->get_var($query);
         // language not found -> insert
         if (empty($lang_id)) {
             // @todo add custom name
             $this->wpdb->insert($table, array('english_name' => $text, 'wp_locale' => $mlp_site['lang'], 'http_name' => str_replace('_', '-', $mlp_site['lang'])));
         } else {
             $this->wpdb->update($table, array('priority' => 10), array('ID' => $lang_id));
         }
     }
 }
开发者ID:luisarn,项目名称:multilingual-press,代码行数:30,代码来源:Mlp_Update_Plugin_Data.php

示例13: wpdb

<h2>Manually Edit Users</h2>
<p>Just in case you need to manually edit or add users</p>

<?php 
require_once SC_USER_DIR . "/library/sc_user_misc.class.php";
$misc = new sc_user_misc();
$scdb = new wpdb(DB_USER, DB_PASSWORD, "uolttorg_sc_data", DB_HOST);
if ($misc->get_post("save") == "Update User") {
    $scdb->update('lttname', array('sc1' => $misc->get_post("sc1"), 'forum' => $misc->get_post("forum"), 'sc2' => $misc->get_post("sc2"), 'rank' => $misc->get_post("rank"), 'role' => $misc->get_post("role"), 'member' => $misc->get_post("member")), array('nameUID' => $misc->get_post("nameUID")));
    // push to RucDoc
    $userdata = array('sc1' => $misc->get_post("sc1"), 'forum' => $misc->get_post("forum"), 'sc2' => $misc->get_post("sc2"), 'rank' => $misc->get_post("rank"), 'role' => $misc->get_post("role"), 'member' => $misc->get_post("member"));
    $url = "http://insanemaths.com/api/api.php?action=update_user&user_id=" . $misc->get_post("nameUID") . "&data=" . str_replace(" ", "+", json_encode($userdata));
    file_get_contents($url);
    // update ship info
    $add = array();
    $remove = array();
    $current = $misc->get_user_ships($misc->get_post('nameUID'));
    for ($i = 0; $i < sizeof($_POST['ships']); $i++) {
        if (!in_array($_POST['ships'][$i], $current)) {
            $add[] = $_POST['ships'][$i];
        }
    }
    for ($i = 0; $i < sizeof($current); $i++) {
        if (!in_array($current[$i], $_POST['ships'])) {
            $remove[] = $current[$i];
        }
    }
    $misc->update_user_ships($misc->get_post('nameUID'), $add, $remove);
}
?>
开发者ID:judahnator,项目名称:uoltt_sc_plugin,代码行数:30,代码来源:user_edit.php

示例14: clean_up_duplicated_translation_ids

 /**
  * Delete duplicate database entries.
  *
  * @param array  $relations Content relations
  * @param string $type      Content type.
  *
  * @return int
  */
 private function clean_up_duplicated_translation_ids(array $relations, $type)
 {
     $result = (int) $this->wpdb->update($this->link_table, array('ml_source_blogid' => $relations[0]['ml_source_blogid'], 'ml_source_elementid' => $relations[0]['ml_source_elementid']), array('ml_source_blogid' => $relations[1]['ml_source_blogid'], 'ml_source_elementid' => $relations[1]['ml_source_elementid'], 'ml_type' => $type), array('%d', '%d'), array('%d', '%d', '%s'));
     do_action('mlp_debug', current_filter() . '/' . __METHOD__ . '/' . __LINE__ . " - {$this->wpdb->last_query}");
     return $result;
 }
开发者ID:luisarn,项目名称:multilingual-press,代码行数:14,代码来源:Mlp_Content_Relations.php

示例15: cron_statusUpdate

function cron_statusUpdate($lead_id, $status, $message)
{
    $wpdb = new wpdb('tpocom_dash', 'w2P!9A-Si0', 'tpocom_dash', 'localhost');
    $table_name = TemplateData::get_tpl_docs_table_name();
    $values = array("cron_status" => $status, "cron_desc" => $message);
    $return = $wpdb->update($table_name, $values, array("lead_id" => $lead_id), array("%d", "%s"), array("%d"));
    return true;
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:8,代码来源:mergedocs.php


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