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


PHP db_delete函数代码示例

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


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

示例1: uninstall_b2evolution

/**
 * Uninstall b2evolution: Delete DB & Cache files
 */
function uninstall_b2evolution()
{
    global $DB;
    /* REMOVE PAGE CACHE */
    load_class('_core/model/_pagecache.class.php', 'PageCache');
    // Remove general page cache
    $PageCache = new PageCache(NULL);
    $PageCache->cache_delete();
    // Skip if T_blogs table is already deleted. Note that db_delete() will not throw any errors on missing tables.
    if ($DB->query('SHOW TABLES LIKE "T_blogs"')) {
        // Get all blogs
        $blogs_SQL = new SQL();
        $blogs_SQL->SELECT('blog_ID');
        $blogs_SQL->FROM('T_blogs');
        $blogs = $DB->get_col($blogs_SQL->get());
        $BlogCache =& get_BlogCache('blog_ID');
        foreach ($blogs as $blog_ID) {
            $Blog = $BlogCache->get_by_ID($blog_ID);
            // Remove page cache of current blog
            $PageCache = new PageCache($Blog);
            $PageCache->cache_delete();
        }
    }
    /* REMOVE DATABASE */
    db_delete();
    echo '<p>' . T_('Reset done!') . '</p>';
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:30,代码来源:_functions_delete.php

示例2: delete

 public function delete($item_id)
 {
     // @TODO - try... catch...
     drupal_set_message("Deleted queue item " . $item_id);
     db_delete('queue')->condition('item_id', $item_id)->execute();
     return TRUE;
 }
开发者ID:selwynpolit,项目名称:elec.aen,代码行数:7,代码来源:QueueUISystemQueue.php

示例3: hook_user_cancel

/**
 * Act on user account cancellations.
 *
 * The user account is being canceled. Depending on the account cancellation
 * method, the module should either do nothing, unpublish content, anonymize
 * content, or delete content and data belonging to the canceled user account.
 *
 * Expensive operations should be added to the global batch with batch_set().
 *
 * @param $edit
 *   The array of form values submitted by the user.
 * @param $account
 *   The user object on which the operation is being performed.
 * @param $method
 *   The account cancellation method.
 *
 * @see user_cancel_methods()
 * @see hook_user_cancel_methods_alter()
 * @see user_cancel()
 */
function hook_user_cancel($edit, $account, $method)
{
    switch ($method) {
        case 'user_cancel_block_unpublish':
            // Unpublish nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            node_mass_update($nodes, array('status' => 0));
            break;
        case 'user_cancel_reassign':
            // Anonymize nodes (current revisions).
            module_load_include('inc', 'node', 'node.admin');
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            node_mass_update($nodes, array('uid' => 0));
            // Anonymize old revisions.
            db_update('node_revision')->fields(array('uid' => 0))->condition('uid', $account->uid)->execute();
            // Clean history.
            db_delete('history')->condition('uid', $account->uid)->execute();
            break;
        case 'user_cancel_delete':
            // Delete nodes (current revisions).
            $nodes = db_select('node', 'n')->fields('n', array('nid'))->condition('uid', $account->uid)->execute()->fetchCol();
            foreach ($nodes as $nid) {
                node_delete($nid);
            }
            // Delete old revisions.
            db_delete('node_revision')->condition('uid', $account->uid)->execute();
            // Clean history.
            db_delete('history')->condition('uid', $account->uid)->execute();
            break;
    }
}
开发者ID:rentasite,项目名称:drupal,代码行数:52,代码来源:user.api.php

示例4: updateDatabase

 /**
  * Remove the record IF there are no records referencing this user.
  */
 function updateDatabase($form, $myvalues)
 {
     //Perform some data quality checks now.
     if (!isset($myvalues['protocol_shortname'])) {
         die("Cannot delete record because missing protocol_shortname in array!\n" . var_dump($myvalues));
     }
     $updated_dt = date("Y-m-d H:i", time());
     $protocol_shortname = $myvalues['protocol_shortname'];
     //Backup all the existing records.
     $this->m_oPageHelper->copyProtocolLibToReplacedTable($protocol_shortname);
     $this->m_oPageHelper->copyKeywordsToReplacedTable($protocol_shortname);
     $this->m_oPageHelper->copyTemplateValuesToReplacedTable($protocol_shortname);
     //Delete all the records.
     $num_deleted = db_delete('raptor_protocol_lib')->condition('protocol_shortname', $protocol_shortname)->execute();
     $num_deleted = db_delete('raptor_protocol_keywords')->condition('protocol_shortname', $protocol_shortname)->execute();
     $num_deleted = db_delete('raptor_protocol_template')->condition('protocol_shortname', $protocol_shortname)->execute();
     //Success?
     if ($num_deleted == 1) {
         $feedback = 'The ' . $protocol_shortname . ' protocol has been succesfully deleted.';
         drupal_set_message($feedback);
         return 1;
     }
     //We are here because we failed.
     $feedback = 'Trouble deleting ' . $protocol_shortname . ' protocol!';
     error_log($feedback . ' delete reported ' . $num_deleted);
     drupal_set_message($feedback, 'warning');
     return 0;
 }
开发者ID:rmurray1,项目名称:RAPTOR,代码行数:31,代码来源:DeleteProtocolLibPage.php

示例5: clear

 /**
  * Removes all URLs and all priority-rules from the URL-cache.
  */
 public function clear()
 {
     // die('clear');
     // drupal_set_message('<pre>PHPCrawlerD7URLCache::clear ' . print_r('', 1) . '</pre>');
     //     $this->conn->query("DELETE FROM " . $this->table . " WHERE crawler_id = '" . $this->crawler_id . "';");
     db_delete($this->table)->condition('crawler_id', $this->crawler_id)->execute();
 }
开发者ID:anselmbradford,项目名称:OpenSanMateo,代码行数:10,代码来源:PHPCrawlerD7URLCache.class.php

示例6: hook_node_convert_change

/**
 * This is an example implementation for the hook. Preforms actions when converting a node based on it's type.
 *
 * @param $data
 *   An array containing information about the conversion process. The keys are
 *   - dest_node_type  The destination type of the node
 *   - node  The node object
 *   - Any other information passed by $op = 'options' or $op = 'options validate'
 * @param $op
 *   A string containing the operation which should be executed. These are the possible values
 *   - insert  Operations which should be run when the node is transferred to the new node type.
 *   Usually for transferring and adding new node information into the database.
 *   - delete  Operations which should be run after the node is transferred to the new node type.
 *   Usually for deleting unneeded information from the database after the transfer.
 *   - options  Configuration elements shown on the conversion form. Should return a FAPI array.
 *   - options validate  Validation check on the options elements.
 * @return
 *    Should return a FAPI array only when using the options operation.
 */
function hook_node_convert_change($data, $op)
{
    // All of this is just an example.
    if ($op == 'insert') {
        if ($data['dest_node_type'] == 'book') {
            $book = array();
            $node = $data['node'];
            $book['link_path'] = 'node/' . $node->nid;
            $book['link_title'] = $node->title;
            $book['plid'] = 0;
            $book['menu_name'] = book_menu_name($node->nid);
            $mlid = menu_link_save($book);
            $book['bid'] = $data['hook_options']['bid'];
            if ($book['bid'] == 'self') {
                $book['bid'] = $node->nid;
            }
            $id = db_insert('book')->fields(array('nid' => $node->nid, 'mlid' => $book['mlid'], 'bid' => $book['bid']))->execute();
        }
        if ($data['dest_node_type'] == 'forum') {
            $id = db_insert('forum')->fields(array('tid' => $data['hook_options']['forum'], 'vid' => $data['node']->vid, 'nid' => $data['node']->nid))->execute();
            $id = db_insert('taxonomy_term_node')->fields(array('tid' => $data['hook_options']['forum'], 'vid' => $data['node']->vid, 'nid' => $data['node']->nid))->execute();
        }
    } elseif ($op == 'delete') {
        if ($data['node']->type == 'book') {
            menu_link_delete($data['node']->book['mlid']);
            db_delete('book')->condition('mlid', $data['node']->book['mlid'])->execute();
        }
        if ($data['node']->type == 'forum') {
            db_delete('forum')->condition('nid', $data['node']->nid)->execute();
            db_delete('taxonomy_term_node')->condition('nid', $data['node']->nid)->execute();
        }
    } elseif ($op == 'options') {
        $form = array();
        if ($data['dest_node_type'] == 'book') {
            foreach (book_get_books() as $book) {
                $options[$book['nid']] = $book['title'];
            }
            $options = array('self' => '<' . t('create a new book') . '>') + $options;
            $form['bid'] = array('#type' => 'select', '#title' => t('Book'), '#options' => $options, '#description' => t('Your page will be a part of the selected book.'), '#attributes' => array('class' => 'book-title-select'));
        }
        if ($data['dest_node_type'] == 'forum') {
            $vid = variable_get('forum_nav_vocabulary', '');
            $form['forum'] = taxonomy_form($vid);
            $form['forum']['#weight'] = 7;
            $form['forum']['#required'] = TRUE;
            $form['forum']['#options'][''] = t('- Please choose -');
        }
        return $form;
    } elseif ($op == 'options validate') {
        $form_state = $data['form_state'];
        if ($data['dest_node_type'] == 'forum') {
            $containers = variable_get('forum_containers', array());
            $term = $form_state['values']['hook_options']['forum'];
            if (in_array($term, $containers)) {
                $term = taxonomy_term_load($term);
                form_set_error('hook_options][forum', t('The item %forum is only a container for forums. Please select one of the forums below it.', array('%forum' => $term->name)));
            }
        }
    }
}
开发者ID:ehazell,项目名称:AWBA,代码行数:79,代码来源:node_convert.api.php

示例7: delete

 public function delete()
 {
     if (!is_numeric($this->record['pid']) || self::load($this->record['pid']) === false) {
         throw new \Exception('The record being deleted does not exist.');
     }
     db_delete('ablecore_menu_item_path')->condition('pid', $this->record['pid'])->execute();
 }
开发者ID:ryne-andal,项目名称:ablecore,代码行数:7,代码来源:MenuPathRelationship.php

示例8: updateDatabase

 /**
  * Actually removes the record IF there are no records referencing this user.
  * If records do reference it, then only marks it inactive.
  */
 function updateDatabase($myvalues)
 {
     $bHasReferences = UserInfo::userIsReferenced($this->m_nUID);
     $feedback = NULL;
     if ($bHasReferences) {
         $updated_dt = date("Y-m-d H:i", time());
         $nUpdated = db_update('raptor_user_profile')->fields(array('accountactive_yn' => 0, 'updated_dt' => $updated_dt))->condition('uid', $this->m_nUID, '=')->execute();
         if ($nUpdated !== 1) {
             error_log("Failed to edit user back to database!\n" . var_dump($myvalues));
             die("Failed to edit user back to database!\n" . var_dump($myvalues));
         }
         $feedback = 'Marked user as inactive instead of deleted because referenced by other records.';
     } else {
         //Delete all the child records first.
         $num_deleted = db_delete('raptor_user_modality')->condition('uid', $this->m_nUID, '=')->execute();
         $num_deleted = db_delete('raptor_user_anatomy')->condition('uid', $this->m_nUID, '=')->execute();
         $num_deleted = db_delete('raptor_user_group_membership')->condition('uid', $this->m_nUID, '=')->execute();
         //Now delete the profile.
         $num_deleted = db_delete('raptor_user_profile')->condition('uid', $this->m_nUID, '=')->execute();
         if ($this->m_nUID == 1) {
             //Do NOT delete this drupal user or will be very unhappy!
             error_log('Removed user 1 from RAPTOR but left it alone in Drupal users table.');
             $feedback = 'Removed user from RAPTOR system.';
         } else {
             //Now delete the Drupal user.
             $num_deleted = db_delete('users')->condition('uid', $this->m_nUID, '=')->execute();
             $feedback = 'Removed the ADMIN user from RAPTOR system.';
         }
     }
     drupal_set_message($feedback);
     return 1;
 }
开发者ID:rmurray1,项目名称:RAPTOR,代码行数:36,代码来源:DeleteUserPage.php

示例9: Destroy

 function Destroy()
 {
     $this->service->PerformDeletion();
     if ($this->id > 0) {
         db_delete('service', '`id`=' . $this->id);
     }
 }
开发者ID:Nazg-Gul,项目名称:gate,代码行数:7,代码来源:service.php

示例10: session_test

function session_test()
{
    tem_load('code/wfpl/test/session_test.html');
    db_delete('wfpl_sessions');
    db_delete('wfpl_session_data');
    session_dump('Clean slate');
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_dump('username jason');
    session_set('username', 'phil');
    session_dump('overwrote username as phil');
    $old = $GLOBALS['session_id'];
    session_new();
    session_dump('new session');
    session_set('username', 'jason');
    session_set('bamph', 'foo');
    session_dump('set username=jason and bamph=foo in new session');
    session_clear('username');
    session_dump('cleared username in new session');
    _kill_session($old);
    session_dump('killed old session');
    kill_session();
    session_dump('kill_session()');
    tem_output();
}
开发者ID:JoshuaGrams,项目名称:wfpl,代码行数:26,代码来源:session_test.php

示例11: submitImportForm

 /**
  * Submits form with invalid, empty, and valid OPML files.
  */
 protected function submitImportForm()
 {
     $before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
     $form['files[upload]'] = $this->getInvalidOpml();
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import'));
     $this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.');
     $edit = array('remote' => file_create_url($this->getEmptyOpml()));
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
     $this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.');
     $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
     $this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.');
     db_delete('aggregator_feed')->execute();
     $feeds[0] = $this->getFeedEditArray();
     $feeds[1] = $this->getFeedEditArray();
     $feeds[2] = $this->getFeedEditArray();
     $edit = array('files[upload]' => $this->getValidOpml($feeds), 'refresh' => '900');
     $this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
     $this->assertRaw(t('A feed with the URL %url already exists.', array('%url' => $feeds[0]['url[0][value]'])), 'Verifying that a duplicate URL was identified');
     $this->assertRaw(t('A feed named %title already exists.', array('%title' => $feeds[1]['title[0][value]'])), 'Verifying that a duplicate title was identified');
     $after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
     $this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
     $feeds_from_db = db_query("SELECT title, url, refresh FROM {aggregator_feed}");
     $refresh = TRUE;
     foreach ($feeds_from_db as $feed) {
         $title[$feed->url] = $feed->title;
         $url[$feed->title] = $feed->url;
         $refresh = $refresh && $feed->refresh == 900;
     }
     $this->assertEqual($title[$feeds[0]['url[0][value]']], $feeds[0]['title[0][value]'], 'First feed was added correctly.');
     $this->assertEqual($url[$feeds[1]['title[0][value]']], $feeds[1]['url[0][value]'], 'Second feed was added correctly.');
     $this->assertTrue($refresh, 'Refresh times are correct.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:35,代码来源:ImportOpmlTest.php

示例12: delete

 /**
  * Delete an entry from the database.
  *
  */
 public static function delete($entry = array())
 {
     $select = db_delete('ea_contact_method_values');
     foreach ($entry as $field => $value) {
         $select->condition($field, $value);
     }
     $select->execute();
 }
开发者ID:Roensby,项目名称:effective-activism-old,代码行数:12,代码来源:EAContactMethodValuesStorage.php

示例13: 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

示例14: delete

 function delete($id)
 {
     if (db_delete($this->table, $this->primary_key . "=" . $id)) {
         return db_delete('order', 'transaction_id=' . $id);
     } else {
         return mysql_affected_rows();
     }
 }
开发者ID:anhnt0212,项目名称:simple-php-mvc,代码行数:8,代码来源:transaction.php

示例15: __db_delete

 public function __db_delete()
 {
     $id_key = $this->id_key();
     $this->switch_to_db();
     db_delete($this->db_table())->condition($id_key, $this->{$id_key})->execute();
     $this->switch_from_db();
     return $this;
 }
开发者ID:Garth619,项目名称:wines-by-jennifer,代码行数:8,代码来源:db_aware_object.php


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