delete() public method

wpdb::delete( 'table', array( 'ID' => 1 ) ) wpdb::delete( 'table', array( 'ID' => 1 ), array( '%d' ) )
See also: wpdb::prepare()
See also: wpdb::$field_types
See also: wp_set_wpdb_vars()
Since: 3.4.0
public delete ( string $table, array $where, array | string $where_format = null ) : integer | false
$table string table name
$where array A named array of WHERE clauses (in column => value pairs). Multiple clauses will be joined with ANDs. Both $where columns and $where values should be "raw".
$where_format array | string Optional. An array of formats to be mapped to each of the values in $where. If string, that format will be used for all of the items in $where. A format is one of '%d', '%f', '%s' (integer, float, string). If omitted, all values in $where will be treated as strings unless otherwise specified in wpdb::$field_types.
return integer | false The number of rows updated, or false on error.
Exemplo n.º 1
0
 /**
  * Delete a specfic ruleset from database.
  *
  * @param int $rulesetId Primary key of the ruleset.
  * @return bool True if ruleset was deleted or false otherwise.
  */
 public function deleteRuleset($rulesetId)
 {
     if (empty($rulesetId)) {
         return false;
     }
     $deleteResult = $this->wpdb->delete($this->wpdb->rulesets, array('id' => (int) $rulesetId));
     return $deleteResult === false ? false : true;
 }
Exemplo n.º 2
0
 /**
  * Delete entity from database.
  *
  * @return int|false
  */
 public function delete()
 {
     if ($this->values['id']) {
         return $this->wpdb->delete($this->table_name, array('id' => $this->values['id']), array('%d'));
     }
     return false;
 }
Exemplo n.º 3
0
 public function save()
 {
     $staff_id = $this->data['staff_id'];
     if ($staff_id) {
         $this->wpdb->delete(AB_StaffService::getTableName(), array('staff_id' => $staff_id), array('%d'));
         if (isset($this->data['service'])) {
             foreach ($this->data['service'] as $service_id) {
                 $staffService = new AB_StaffService();
                 $staffService->set('service_id', $service_id);
                 $staffService->set('staff_id', $staff_id);
                 $staffService->set('price', $this->data['price'][$service_id]);
                 $staffService->set('capacity', $this->data['capacity'][$service_id]);
                 $staffService->save();
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Deletes the record of the passed ID
  *
  * @since 2.0.0
  *
  * @param int $id ID of the record to delete
  *
  * @return bool
  * @throws Exception
  */
 public function remove($id)
 {
     // Make sure the ID passed is an integer.
     if (!is_int($id)) {
         throw new Exception(__('A numerical ID must be passed.', 'optin-monster'));
     }
     // Setup the WHERE clause.
     $where = array('lead_id' => $id);
     // Delete the record.
     if (false == $this->db->delete($this->table, $where)) {
         throw new Exception(__('There was an error deleting the lead.', 'optin-monster'));
     } else {
         return true;
     }
 }
Exemplo n.º 5
0
 /**
  * @param  int    $source_site_id
  * @param  int    $target_site_id
  * @param  int    $source_content_id  post_id or term_taxonomy_id
  * @param  int    $target_content_id
  * @param  string $type
  * @return int                        Number of deleted rows
  */
 public function delete_relation($source_site_id, $target_site_id, $source_content_id, $target_content_id = 0, $type = 'post')
 {
     $where = array('ml_source_blogid' => $source_site_id, 'ml_source_elementid' => $source_content_id, 'ml_type' => $type);
     $where_format = array('%d', '%d', '%s');
     if (0 < $target_site_id) {
         $where['ml_blogid'] = $target_site_id;
         $where_format[] = '%d';
     }
     if (0 < $target_content_id) {
         $where['ml_elementid'] = $target_content_id;
         $where_format[] = '%d';
     }
     $result = (int) $this->wpdb->delete($this->link_table, $where, $where_format);
     do_action('mlp_debug', current_filter() . '/' . __METHOD__ . '/' . __LINE__ . " - {$this->wpdb->last_query}");
     return $result;
 }
Exemplo n.º 6
0
 public function drop_subscription($fromsub_id)
 {
     if (!apply_filters('pre_membership_drop_subscription', true, $fromsub_id, $this->ID) || !$this->on_sub($fromsub_id)) {
         return false;
     }
     // Get the level for this subscription before removing it
     $fromlevel_id = $this->get_level_for_sub($fromsub_id);
     $this->_wpdb->delete(MEMBERSHIP_TABLE_RELATIONS, array('user_id' => $this->ID, 'sub_id' => $fromsub_id), array('%d', '%d'));
     // 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);
     delete_user_meta($this->ID, 'using_gateway_' . $fromsub_id);
     $expiring = get_user_meta($this->ID, '_membership_expire_next', true);
     if ($expiring == $fromsub_id) {
         delete_user_meta($this->ID, '_membership_expire_next');
     }
     $this->set_role(get_option('default_role'));
     do_action('membership_drop_subscription', $fromsub_id, $fromlevel_id, $this->ID);
     return true;
 }
Exemplo n.º 7
0
 protected function actionUnlicenseSite($productSlug, $licenseKey = null, $token = null)
 {
     $this->requireRequestMethod('POST');
     $license = $this->validateLicenseRequest($productSlug, $licenseKey, $token, $this->post);
     $siteUrl = $this->sanitizeSiteUrl(isset($this->post['site_url']) ? strval($this->post['site_url']) : '');
     $usingToken = !empty($token);
     $response = array('license' => $this->prepareLicenseForOutput($license, $usingToken));
     if (!$usingToken) {
         $token = $this->wpdb->get_var($this->wpdb->prepare("SELECT token FROM `{$this->tablePrefix}tokens` WHERE site_url = %s AND license_id = %d", $siteUrl, $license['license_id']));
     }
     if (empty($token)) {
         //The user tried to un-license a site that wasn't licensed in the first place. Still,
         //the desired end state - site not licensed - has ben achieved, so treat it as a success.
         $response['notice'] = "The specified site wasn't licensed in the first place.";
     } else {
         $this->wpdb->delete($this->tablePrefix . 'tokens', array('token' => $token, 'license_id' => $license['license_id']));
         //Reload the license to ensure the site list is correct.
         $license = $this->loadLicense($license['license_key']);
         $response['license'] = $this->prepareLicenseForOutput($license, $usingToken);
         $response = array_merge($response, array('site_token_removed' => $token, 'site_url' => $siteUrl));
     }
     $this->outputResponse($response);
 }
Exemplo n.º 8
0
 /**
  *
  * @param string $email
  * @param string $name
  *
  * @return false|int|void
  */
 public function removeSubscriber($id)
 {
     return $this->wpdb->delete($this->table, ['id' => $id]);
 }
 /**
  *
  * @return $this
  */
 public function delete()
 {
     $this->tm_records->icl_translation_status_by_translation_id($this->translation_id)->delete();
     $this->wpdb->delete($this->wpdb->prefix . $this->table, $this->get_args());
     return $this;
 }
Exemplo n.º 10
0
 /**
  * Delete a row in the table
  *
  * @see wpdb::delete()
  */
 public function deleteRow($where, $where_format = null)
 {
     return $this->db->delete($this->schema->table_name, $where, $where_format);
 }
Exemplo n.º 11
0
 function remove_level_members($id, $levels)
 {
     foreach ($levels as $level) {
         $this->db->delete(MEMBERSHIP_TABLE_RELATIONS, array('sub_id' => $this->id, 'level_id' => $level->id), array('%d', '%d'));
     }
 }
 /**
  * Delete a form.
  *
  * @author Jeremy Pry
  *
  * @param int $form_id The form ID to delete.
  *
  * @return bool Whether the form was successfully deleted.
  */
 public function delete_form($form_id)
 {
     return (bool) $this->wpdb->delete($this->prefixed_table_name, array('id' => $form_id), '%d');
 }
Exemplo n.º 13
0
 function delete()
 {
     return $this->db->delete(MEMBERSHIP_TABLE_COMMUNICATIONS, array('id' => $this->id), array('%d'));
 }
Exemplo n.º 14
0
 /**
  * Delete taxonomy meta
  *
  * @param int $term_id
  * @param string $key
  * @return int
  */
 public function delete($term_id, $key)
 {
     wp_cache_delete($this->_get_cache_key($term_id, $key), 'taxonomy-meta');
     return $this->_db->delete($this->_table, ['term_id' => $term_id, 'meta_key' => $key]);
 }
Exemplo n.º 15
0
<h2>Star Citizen Ships</h2>
<p>Cool Ship Stuff!</p>


<?php 
// saves data
$scdb = new wpdb(DB_USER, DB_PASSWORD, "uolttorg_sc_data", DB_HOST);
if (isset($_POST['delete_ship'])) {
    foreach ($_POST['delete_ship'] as $id) {
        $scdb->delete("ships", array("shipUID" => $id));
    }
    unset($_POST['delete_ship']);
}
if (isset($_POST['add_edit_ship'])) {
    if ($_POST['add_edit_ship'] == "add") {
        unset($_POST['add_edit_ship']);
        $err_c = 0;
        foreach ($_POST as $k => $v) {
            if (empty($v)) {
                echo '<div class="error notice"><p>Please set the "' . $k . '" field!</p></div>';
                $err_c++;
            }
        }
        if ($err_c == 0) {
            $scdb->insert("ships", $_POST);
        }
    } elseif ($_POST['add_edit_ship'] != "add" && $_POST['add_edit_ship'] != "") {
        $data = array();
        foreach ($_POST as $k => $v) {
            if ($v != "" && $k != "add_edit_ship") {
                $data[$k] = $v;