本文整理汇总了PHP中db_update函数的典型用法代码示例。如果您正苦于以下问题:PHP db_update函数的具体用法?PHP db_update怎么用?PHP db_update使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_update函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WT_ResetStatus
function WT_ResetStatus()
{
if (!WT_IPC_CheckLogin()) {
return;
}
db_update('tester_solutions', array('status' => 0), '`status`=1');
}
示例2: saveToActiveStore
/**
* Implements Drupal\configuration\Config\Configuration::saveToActiveStore().
*/
public function saveToActiveStore(ConfigIteratorSettings &$settings)
{
ctools_include('export');
$object = ctools_export_crud_load($this->getComponent(), $this->getIdentifier());
if ($object) {
ctools_export_crud_delete($this->getComponent(), $object);
}
$data = $this->getData();
$data->export_type = NULL;
// get title_pane key if configured.
if (isset($data->conf['display']->title_pane)) {
$title_pane = $data->conf['display']->title_pane;
}
$display = panels_save_display($data->conf['display']);
// title_pane configuration workaround.
if (isset($display->content[$title_pane])) {
$pid = $display->content[$title_pane]->pid;
$display->{$title_pane} = $pid;
db_update('panels_display')->fields(array('title_pane' => $pid))->condition('did', $display->did)->execute();
}
$data->conf['did'] = $data->conf['display']->did;
unset($data->conf['display']);
ctools_export_crud_save($this->getComponent(), $data);
$settings->addInfo('imported', $this->getUniqueId());
}
示例3: 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;
}
示例4: release
public function release($item_id)
{
// @TODO - try... catch...
drupal_set_message("Released queue item " . $item_id);
db_update('queue')->condition('item_id', $item_id)->fields(array('expire' => 0))->execute();
return TRUE;
}
示例5: put
public function put($id = false)
{
$result = jsonSrc();
if ($id) {
$updatePage['author'] = false;
$updatePage['update'] = time();
$updatePage['url'] = $this->input->post('url');
$updatePage['title'] = $this->input->post('title');
$updatePage['title_en'] = $this->input->post('title_en');
$updatePage['excerpt'] = $this->input->post('excerpt');
$updatePage['excerpt_en'] = $this->input->post('excerpt_en');
$updatePage['content'] = $this->input->post('content');
$updatePage['content_en'] = $this->input->post('content_en');
$updatePage['meta_key'] = $this->input->post('meta_key');
$updatePage['meta_key_en'] = $this->input->post('meta_key_en');
$updatePage['meta_desc'] = $this->input->post('meta_desc');
$updatePage['meta_desc_en'] = $this->input->post('meta_desc_en');
$updatePage['template'] = $this->input->post('template');
$updatePage['image'] = $this->input->post('image');
$updatePage['image2'] = $this->input->post('image2');
$updatePage['status'] = $this->input->post('status');
$updatePage['tag'] = $this->input->post('tag');
if ($this->input->post('pengumuman')) {
$updatePage['catid'] = 9;
} else {
$updatePage['catid'] = 0;
}
$updatePage['type'] = 'news';
db_update('page', array('id' => $id), $updatePage);
$result['resultCode'] = 1000;
$result['resultMsg'] = "Success !!";
}
return $result;
}
示例6: edit
function edit($id = false)
{
if (empty($_POST)) {
$category = db_read('category');
if (!$category) {
redirect(base_url('admin/category/add'));
}
if (!$id) {
$id = $category->id;
}
$view['blogs'] = db_reads('page', array('type' => 'blog', 'catid' => $id));
$view['categories'] = db_reads('category', array('type' => 'blog'));
$view['category'] = db_read('category', array('id' => $id, 'type' => 'blog'));
$this->load->view(tpldir('admin/category/edit_view'), $view);
} else {
$result = jsonSrc();
$id = $this->input->post('id');
$updatecat['name'] = $this->input->post('name');
db_update('category', array('id' => $id), $updatecat);
$result['resultCode'] = 1000;
$result['resultMsg'] = "Success!!";
$result['resultData']['openUrl'] = base_url('admin/category/edit/' . $id);
echo json_encode($result);
}
}
示例7: testContentAdminSort
/**
* Tests that the table sorting works on the content admin pages.
*/
function testContentAdminSort()
{
$this->drupalLogin($this->adminUser);
$changed = REQUEST_TIME;
foreach (array('dd', 'aa', 'DD', 'bb', 'cc', 'CC', 'AA', 'BB') as $prefix) {
$changed += 1000;
$node = $this->drupalCreateNode(array('title' => $prefix . $this->randomMachineName(6)));
db_update('node_field_data')->fields(array('changed' => $changed))->condition('nid', $node->id())->execute();
}
// Test that the default sort by node.changed DESC actually fires properly.
$nodes_query = db_select('node_field_data', 'n')->fields('n', array('title'))->orderBy('changed', 'DESC')->execute()->fetchCol();
$this->drupalGet('admin/content');
foreach ($nodes_query as $delta => $string) {
$elements = $this->xpath('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', array(':class' => 'views-table', ':label' => $string));
$this->assertTrue(!empty($elements), 'The node was found in the correct order.');
}
// Compare the rendered HTML node list to a query for the nodes ordered by
// title to account for possible database-dependent sort order.
$nodes_query = db_select('node_field_data', 'n')->fields('n', array('title'))->orderBy('title')->execute()->fetchCol();
$this->drupalGet('admin/content', array('query' => array('sort' => 'asc', 'order' => 'title')));
foreach ($nodes_query as $delta => $string) {
$elements = $this->xpath('//table[contains(@class, :class)]/tbody/tr[' . ($delta + 1) . ']/td[2]/a[normalize-space(text())=:label]', array(':class' => 'views-table', ':label' => $string));
$this->assertTrue(!empty($elements), 'The node was found in the correct order.');
}
}
示例8: ajax_store_vote
static function ajax_store_vote($folder, $votes)
{
self::_require_access($folder, "read");
if (empty($votes) or !is_array($votes)) {
return "";
}
foreach ($votes as $qid => $vote_elems) {
if (!is_array($vote_elems) or implode("", $vote_elems) == "") {
continue;
}
$row = db_select_first("simple_surveys", "answers,votedby", "id=@id@", "", array("id" => $qid));
if (empty($row)) {
continue;
}
$answers = json_decode($row["answers"], true);
$votedby = json_decode($row["votedby"], true);
$id = self::_get_voter_id();
if (isset($votedby[$id])) {
exit("{t}Already voted.{/t} (" . $qid . ")");
}
foreach ($vote_elems as $vote_elem) {
if ($vote_elem == "") {
continue;
}
if (!isset($answers[$vote_elem])) {
$answers[$vote_elem] = 0;
}
$answers[$vote_elem]++;
}
$votedby[$id] = 0;
db_update("simple_surveys", array("votedby" => json_encode($votedby), "answers" => json_encode($answers)), array("id=@id@"), array("id" => $qid));
}
return $folder;
}
示例9: 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;
}
}
示例10: send
function send()
{
global $keystring, $login, $email;
$hash = md5('#RANDOM_PREFIX#' . mtime() . '#RANDOM_SEPARATOR#' . $login . '#WITH#' . $email . '#RANDOM_SUFFIX#');
if ($_SESSION['CAPTCHA_Keystring'] == '' || strtolower($keystring) != $_SESSION['CAPTCHA_Keystring']) {
add_info('Вы не прошли тест Тьюринга на подтверждение того, что вы не бот.');
return false;
}
$r = db_row_value('user', "(`login` =\"{$login}\") AND (`email`=\"{$email}\") AND (`authorized`=1)");
if ($r['id'] == '') {
add_info('Неверное сочетание login <-> email');
return false;
}
$s = unserialize($r['settings']);
if ($s['restore_timestamp'] && time() - $s['restore_timestamp'] < config_get('restore-timeout')) {
add_info('Вы не можете просить восстановку пароля так часто');
return false;
}
$s['restore_hash'] = $hash;
$s['restore_timestamp'] = time();
db_update('user', array('settings' => db_string(serialize($s))), '`id`=' . $r['id']);
$link = config_get('http-document-root') . '/login/restore/confirm/?id=' . $r['id'] . '&hash=' . $hash;
sendmail_tpl(stripslashes($email), 'Восстановление пароля в системе ' . config_get('site-name'), 'restore', array('login' => stripslashes($login), 'email' => stripslashes($email), 'link' => $link));
return true;
}
示例11: put
public function put($id = false)
{
$result = jsonSrc();
if ($id) {
$updatePage['date'] = strtotime($this->input->post('date'));
$updatePage['url'] = $this->input->post('url');
$updatePage['title'] = $this->input->post('title');
$updatePage['title_en'] = $this->input->post('title_en');
$updatePage['excerpt'] = $this->input->post('excerpt');
$updatePage['excerpt_en'] = $this->input->post('excerpt_en');
$updatePage['content'] = $this->input->post('content');
$updatePage['content_en'] = $this->input->post('content_en');
$updatePage['meta_key'] = $this->input->post('meta_key');
$updatePage['meta_key_en'] = $this->input->post('meta_key_en');
$updatePage['meta_desc'] = $this->input->post('meta_desc');
$updatePage['meta_desc_en'] = $this->input->post('meta_desc_en');
$updatePage['template'] = $this->input->post('template');
$updatePage['image'] = $this->input->post('image');
$updatePage['status'] = $this->input->post('status');
$updatePage['type'] = 'event';
db_update('page', array('id' => $id), $updatePage);
$result['resultCode'] = 1000;
$result['resultMsg'] = "Success !!";
}
return $result;
}
示例12: testUpdateFeedItem
/**
* Tests running "update items" from 'admin/config/services/aggregator' page.
*/
public function testUpdateFeedItem()
{
$this->createSampleNodes();
// Create a feed and test updating feed items if possible.
$feed = $this->createFeed();
if (!empty($feed)) {
$this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
$this->deleteFeedItems($feed);
}
// Delete feed.
$this->deleteFeed($feed);
// Test updating feed items without valid timestamp information.
$edit = array('title[0][value]' => "Feed without publish timestamp", 'url[0][value]' => $this->getRSS091Sample());
$this->drupalGet($edit['url[0][value]']);
$this->assertResponse(200);
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
$fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField();
$feed = Feed::load($fid);
$feed->refreshItems();
$before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
// Sleep for 3 second.
sleep(3);
db_update('aggregator_feed')->condition('fid', $feed->id())->fields(array('checked' => 0, 'hash' => '', 'etag' => '', 'modified' => 0))->execute();
$feed->refreshItems();
$after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
$this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', array('@before' => $before, '@after' => $after)));
// Make sure updating items works even after uninstalling a module
// that provides the selected plugins.
$this->enableTestPlugins();
$this->container->get('module_installer')->uninstall(array('aggregator_test'));
$this->updateFeedItems($feed);
$this->assertResponse(200);
}
示例13: api_graph_template_suggested_values_save
function api_graph_template_suggested_values_save($graph_template_id, $_fields_suggested_values) {
require_once(CACTI_BASE_PATH . "/lib/sys/sequence.php");
/* sanity checks */
validate_id_die($graph_template_id, "graph_template_id");
/* insert the new custom field values */
if (is_array($_fields_suggested_values) > 0) {
foreach ($_fields_suggested_values as $field_name => $field_array) {
foreach ($field_array as $field_item) {
if (empty($field_item["id"])) {
db_insert("graph_template_suggested_value",
array(
"id" => array("type" => DB_TYPE_INTEGER, "value" => "0"),
"graph_template_id" => array("type" => DB_TYPE_INTEGER, "value" => $graph_template_id),
"field_name" => array("type" => DB_TYPE_STRING, "value" => $field_name),
"value" => array("type" => DB_TYPE_STRING, "value" => $field_item["value"]),
"sequence" => array("type" => DB_TYPE_INTEGER, "value" => seq_get_current(0, "sequence", "graph_template_suggested_value", "graph_template_id = " . sql_sanitize($graph_template_id) . " and field_name = '" . sql_sanitize($field_name) . "'"))
),
array("id"));
}else{
db_update("graph_template_suggested_value",
array(
"id" => array("type" => DB_TYPE_INTEGER, "value" => $field_item["id"]),
"value" => array("type" => DB_TYPE_STRING, "value" => $field_item["value"])
),
array("id"));
}
}
}
}
}
示例14: bill_detail
function bill_detail()
{
$data = array();
$user = adminLogged();
if (!adminLogged()) {
redirect('/index.php?c=admin&m=login');
} else {
$bill_detail = model('bill')->getBillDetails($_GET['id']);
$data['total'] = 0;
foreach ($bill_detail as $key => $b) {
$book = model('book')->getSingle($b['book_id']);
$bill_detail[$key]['name'] = $book['name'];
$bill_detail[$key]['price'] = intval($book['price']);
$bill_detail[$key]['total'] = $book['price'] * $b['quantity'];
$bill_detail[$key]['image'] = $book['image'];
$data['total'] += $book['price'] * $b['quantity'];
}
$data['bill_detail'] = $bill_detail;
}
$data['statuses'] = array('Chờ duyệt', 'Đang giao hàng', 'Đã giao hàng', 'Hủy');
$data['stt'] = model('bill')->getOneBy($_GET['id'], null)['status'];
if (isPostRequest()) {
$postData = postData();
db_update('bills', $postData, 'id=' . $_GET['id']);
$data['stt'] = $postData['status'];
$data['error'] = 'Tình trạng đơn hàng update thành công.';
}
$data['user'] = model('user')->getOneBy(model('bill')->getOneBy($_GET['id'], null)['user_id'], null);
$data['template_file'] = 'bill/detail.php';
render('layout.php', $data);
}
示例15: update_db_user_projects
function update_db_user_projects($user, $project, $is_frozen)
{
if (!$is_frozen) {
$is_frozen = '0';
}
db_update('flat_deposit_ui_project_info')->fields(array('is_frozen' => $is_frozen))->condition('user_id', $user)->condition('pname', $project)->execute();
}