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


PHP Database::query_update方法代码示例

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


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

示例1: UpdateSettings

function UpdateSettings($setting, $val, $type = '')
{
    global $server, $user, $pass, $database, $pre;
    if (empty($type)) {
        $type = 'admin';
    }
    //Connect to database
    require_once "sources/class.database.php";
    $db = new Database($server, $user, $pass, $database, $pre);
    $db->connect();
    //Check if setting is already in DB. If NO then insert, if YES then update.
    $data = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "misc WHERE type='" . $type . "' AND intitule = '" . $setting . "'");
    if ($data[0] == 0) {
        $db->query_insert("misc", array('valeur' => $val, 'type' => $type, 'intitule' => $setting));
        //in case of stats enabled, add the actual time
        if ($setting == 'send_stats') {
            $db->query_insert("misc", array('valeur' => time(), 'type' => $type, 'intitule' => $setting . '_time'));
        }
    } else {
        $db->query_update("misc", array('valeur' => $val), "type='" . $type . "' AND intitule = '" . $setting . "'");
        //in case of stats enabled, update the actual time
        if ($setting == 'send_stats') {
            //Check if previous time exists, if not them insert this value in DB
            $data_time = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "misc WHERE type='" . $type . "' AND intitule = '" . $setting . "_time'");
            if ($data_time[0] == 0) {
                $db->query_insert("misc", array('valeur' => 0, 'type' => $type, 'intitule' => $setting . '_time'));
            } else {
                $db->query_update("misc", array('valeur' => 0), "type='" . $type . "' AND intitule = '" . $setting . "_time'");
            }
        }
    }
    //save in variable
    if ($type == "admin") {
        $_SESSION['settings'][$setting] = $val;
    } else {
        if ($type == "settings") {
            $settings[$setting] = $val;
        }
    }
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:40,代码来源:admin.settings.php

示例2: COUNT

 if ($manage_kb == true) {
     $label = utf8_decode($_POST['label']);
     $category = utf8_decode($_POST['category']);
     $description = utf8_decode($_POST['description']);
     //Add category if new
     $data = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "kb_categories WHERE category = '" . mysql_real_escape_string($category) . "'");
     if ($data[0] == 0) {
         $cat_id = $db->query_insert("kb_categories", array('category' => mysql_real_escape_string($category)));
     } else {
         //get the ID of this existing category
         $cat_id = $db->fetch_row("SELECT id FROM " . $pre . "kb_categories WHERE category = '" . mysql_real_escape_string($category) . "'");
         $cat_id = $cat_id[0];
     }
     if (isset($_POST['id']) && !empty($_POST['id'])) {
         //update KB
         $new_id = $db->query_update("kb", array('label' => $label, 'description' => mysql_real_escape_string($description), 'author_id' => $_SESSION['user_id'], 'category_id' => $cat_id, 'anyone_can_modify' => $_POST['anyone_can_modify']), "id='" . $_POST['id'] . "'");
     } else {
         //add new KB
         $new_id = $db->query_insert("kb", array('label' => $label, 'description' => mysql_real_escape_string($description), 'author_id' => $_SESSION['user_id'], 'category_id' => $cat_id, 'anyone_can_modify' => $_POST['anyone_can_modify']));
     }
     //delete all associated items to this KB
     $db->query_delete("kb_items", array('kb_id' => $_POST['id']));
     //add all items associated to this KB
     foreach (explode(',', $_POST['kb_associated_to']) as $item_id) {
         $db->query_insert("kb_items", array('kb_id' => $_POST['id'], 'item_id' => $item_id));
     }
     echo '$("#kb_form").dialog("close");oTable = $("#t_kb").dataTable();LoadingPage();oTable.fnDraw();';
 } else {
     echo '$("#kb_form").dialog("close");';
 }
 break;
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:kb.queries.php

示例3: array

 #-------------------------------------------
 #CASE delete a role
 case "delete_role":
     $db->query("DELETE FROM " . $pre . "roles_title WHERE id = " . $_POST['id']);
     $db->query("DELETE FROM " . $pre . "roles_values WHERE role_id = " . $_POST['id']);
     //Actualize the variable
     $_SESSION['nb_roles']--;
     //reload page
     echo 'window.location.href = "index.php?page=manage_roles";';
     break;
     #-------------------------------------------
     #CASE editing a role
 #-------------------------------------------
 #CASE editing a role
 case "edit_role":
     $db->query_update("roles_title", array('title' => mysql_real_escape_string(stripslashes($_POST['title']))), 'id = ' . $_POST['id']);
     //reload matrix
     echo 'var data = "type=rafraichir_matrice";httpRequest("sources/roles.queries.php",data);';
     break;
     #-------------------------------------------
     #CASE refresh the matrix
 #-------------------------------------------
 #CASE refresh the matrix
 case "rafraichir_matrice":
     echo 'document.getElementById(\'matrice_droits\').innerHTML = "";';
     require_once "NestedTree.class.php";
     $tree = new NestedTree($pre . 'nested_tree', 'id', 'parent_id', 'title');
     $tree = $tree->getDescendants();
     $texte = '<table><thead><tr><th>' . $txt['group'] . 's</th>';
     $gpes_ok = array();
     $gpes_nok = array();
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:roles.queries.php

示例4: foreach

         $old_pw = "";
         foreach ($last_pw as $elem) {
             if (!empty($elem)) {
                 if (empty($old_pw)) {
                     $old_pw = $elem;
                 } else {
                     $old_pw .= ";" . $elem;
                 }
             }
         }
         //update sessions
         $_SESSION['last_pw'] = $old_pw;
         $_SESSION['last_pw_change'] = mktime(0, 0, 0, date('m'), date('d'), date('y'));
         $_SESSION['validite_pw'] = true;
         //update DB
         $db->query_update("users", array('pw' => $new_pw, 'last_pw_change' => mktime(0, 0, 0, date('m'), date('d'), date('y')), 'last_pw' => $old_pw), "id = " . $_SESSION['user_id']);
         echo '[ { "error" : "none" } ]';
     }
 } else {
     //ADMIN has decided to change the USER's PW
     if (isset($_POST['change_pw_origine']) && $_POST['change_pw_origine'] == "admin_change") {
         //Check KEY
         if ($data_received['key'] != $_SESSION['key']) {
             echo '[ { "error" : "key_not_conform" } ]';
             exit;
         }
         //update DB
         $db->query_update("users", array('pw' => $new_pw, 'last_pw_change' => mktime(0, 0, 0, date('m'), date('d'), date('y'))), "id = " . $data_received['user_id']);
         echo '[ { "error" : "none" } ]';
     } else {
         echo '[ { "error" : "nothing_to_do" } ]';
开发者ID:sleepy909,项目名称:cpassman,代码行数:31,代码来源:main.queries.php

示例5: explode

     $new_groupes = $data[0];
     if (!empty($data[0])) {
         $groupes = explode(';', $data[0]);
         if (in_array($val[1], $groupes)) {
             $new_groupes = str_replace($val[1], "", $new_groupes);
         } else {
             $new_groupes .= ";" . $val[1];
         }
     } else {
         $new_groupes = $val[1];
     }
     while (substr_count($new_groupes, ";;") > 0) {
         $new_groupes = str_replace(";;", ";", $new_groupes);
     }
     //Store id DB
     $db->query_update("users", array($_POST['type'] => $new_groupes), "id = " . $val[0]);
     break;
 case "fonction":
     $val = explode(';', $_POST['valeur']);
     $valeur = $_POST['valeur'];
     //v?rifier si l'id est d?j? pr?sent
     $data = $db->fetch_row("SELECT fonction_id FROM " . $pre . "users WHERE id = {$val['0']}");
     $new_fonctions = $data[0];
     if (!empty($data[0])) {
         $fonctions = explode(';', $data[0]);
         if (in_array($val[1], $fonctions)) {
             $new_fonctions = str_replace($val[1], "", $new_fonctions);
         } else {
             if (!empty($new_fonctions)) {
                 $new_fonctions .= ";" . $val[1];
             } else {
开发者ID:sleepy909,项目名称:cpassman,代码行数:31,代码来源:users.queries.php

示例6:

$sqlAnswer = "Select correct_answer from tblquestions where id='".$question_id."'";

$rowAnswer = $db->query($sqlAnswer);
$result2 = $db->fetch_array($rowAnswer);


$answerResult = "incorrect";
if(isset($_POST["answer"]))
{
	
	if($result2["correct_answer"] == $_POST["answer"]){
		$answerResult = "correct";
	}
		$_POST["status"] = $answerResult;
		$DATA = $_POST;
}else{
	unset($_POST["answer"]);
	$DATA["time_to_answer"] = $_POST["time_to_answer"];
}
	 $row = $db->query_update("tbltemporarygenexam",$DATA,"question_id='".$question_id."' and student_id='".$student_id."'");
	 echo $row;



	
	//echo json_encode($json);
	mysql_close();
	
		
 ?>
开发者ID:AIMHIGHTUITION,项目名称:beta,代码行数:30,代码来源:_updatedata.php

示例7: Database

<?php

/**
 * The plugin control panel, you can manage the plugins activity in this page.
 */
include_once 'phphooks.class.php';
include_once 'includes/database.class.php';
require_once 'config.php';
$db = new Database($mysql_db_host, $mysql_db_user, $mysql_db_passwd, $mysql_db_name, $table_prefix);
$db->connect();
switch ($_GET['action']) {
    case "deactivate":
        $data['action'] = 0;
        $db->query_update("plugins", $data, "filename='" . $_GET['filename'] . "'");
        break;
    case "activate":
        $sql = "SELECT * FROM " . $table_prefix . "plugins WHERE filename = '" . $db->escape($_GET['filename']) . "'";
        $count = count($db->fetch_all_array($sql));
        if ($count < 1) {
            $data['filename'] = $_GET['filename'];
            $data['action'] = 1;
            $db->query_insert("plugins", $data);
        } else {
            $data['action'] = 1;
            $db->query_update("plugins", $data, "filename='" . $_GET['filename'] . "'");
        }
        break;
}
$sql = "SELECT filename, action FROM " . $table_prefix . "plugins WHERE action = '" . $db->escape(1) . "'";
$result_rows = $db->fetch_all_array($sql);
$plugin_list = new phphooks();
开发者ID:sofagris,项目名称:phphooks,代码行数:31,代码来源:control.php

示例8: CPMStats

function CPMStats()
{
    global $server, $user, $pass, $database, $pre;
    require_once 'includes/settings.php';
    // connect to the server
    require_once "class.database.php";
    $db = new Database($server, $user, $pass, $database, $pre);
    $db->connect();
    // Prepare stats to be sent
    // Count no FOLDERS
    $data_folders = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "nested_tree");
    // Count no USERS
    $data_users = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "users");
    // Count no ITEMS
    $data_items = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "items");
    // Get info about installation
    $data_system = array();
    $rows = $db->fetch_all_array("SELECT valeur,intitule FROM " . $pre . "misc WHERE type = 'admin' AND intitule IN ('enable_pf_feature','log_connections','cpassman_version')");
    foreach ($rows as $reccord) {
        if ($reccord['intitule'] == 'enable_pf_feature') {
            $data_system['enable_pf_feature'] = $reccord['valeur'];
        } else {
            if ($reccord['intitule'] == 'cpassman_version') {
                $data_system['cpassman_version'] = $reccord['valeur'];
            } else {
                if ($reccord['intitule'] == 'log_connections') {
                    $data_system['log_connections'] = $reccord['valeur'];
                }
            }
        }
    }
    // Get the actual stats.
    $stats_to_send = array('uid' => md5(SALT), 'time_added' => time(), 'users' => $data_users[0], 'folders' => $data_folders[0], 'items' => $data_items[0], 'cpm_version' => $data_system['cpassman_version'], 'enable_pf_feature' => $data_system['enable_pf_feature'], 'log_connections' => $data_system['log_connections']);
    // Encode all the data, for security.
    foreach ($stats_to_send as $k => $v) {
        $stats_to_send[$k] = urlencode($k) . '=' . urlencode($v);
    }
    // Turn this into the query string!
    $stats_to_send = implode('&', $stats_to_send);
    fopen("http://www.vag-technique.fr/divers/cpm_stats/collect_stats.php?" . $stats_to_send, 'r');
    // update the actual time
    $db->query_update("misc", array('valeur' => time()), "type='admin' AND intitule = 'send_stats_time'");
}
开发者ID:omusico,项目名称:isle-web-framework,代码行数:43,代码来源:main.functions.php

示例9: Database

 */
include_once 'Database.class.php';
define("MSCTBL", "msc");
$db = new Database('localhost', 'root', 'trdc123', 'mscsim');
//connect to the server
$db->connect();
if ($_GET['action'] == 'register' && !empty($_POST['MSISDN']) && !empty($_POST['IMSI'])) {
    $preMSISDN = $_POST['MSISDN'][0] . $_POST['MSISDN'][1] . $_POST['MSISDN'][2] . $_POST['MSISDN'][3];
    $data['TMSI'] = "91" . $preMSISDN . rand('199999', '999999');
    $sql = "SELECT * FROM " . MSCTBL . " WHERE `MSISDN` = '" . $_POST['MSISDN'] . "'";
    $row = $db->query_first($sql);
    if (empty($row)) {
        $error_dat['status'] = "error";
        $error_dat['reason'] = "Registration Failed...";
    } else {
        $db->query_update(MSCTBL, $data, " `MSISDN` = '" . $_POST['MSISDN'] . "' ");
        $error_dat['regdata'] = $row;
        $error_dat['regdata']['TMSI'] = $data['TMSI'];
        $error_dat['status'] = "success";
        $error_dat['reason'] = "Registration Complete...";
    }
    sleep(3);
    echo json_encode($error_dat);
} elseif ($_GET['action'] == 'makesim' && !empty($_POST['MSISDN'])) {
    $preMSISDN = $_POST['MSISDN'][0] . $_POST['MSISDN'][1] . $_POST['MSISDN'][2] . $_POST['MSISDN'][3];
    $data['IMSI'] = "91" . $preMSISDN . rand('199999', '999999');
    $data['IMEI'] = "956647" . "894467" . rand('199999', '999999');
    $data['Ki'] = genRandKey(128);
    $data['NSP'] = getNSP($preMSISDN);
    $sql = "SELECT * FROM " . MSCTBL . " WHERE `MSISDN` = '" . $_POST['MSISDN'] . "'";
    $row = $db->query_first($sql);
开发者ID:TreforJohn,项目名称:a3-algorithm,代码行数:31,代码来源:functions.php

示例10: die

    die('Hacking attempt...');
}
include '../includes/language/' . $_SESSION['user_language'] . '.php';
include '../includes/settings.php';
header("Content-type: text/html; charset==utf-8");
include 'main.functions.php';
require_once "NestedTree.class.php";
//Connect to mysql server
require_once "class.database.php";
$db = new Database($server, $user, $pass, $database, $pre);
$db->connect();
// CASE where title is changed
if (isset($_POST['newtitle'])) {
    $id = explode('_', $_POST['id']);
    //update DB
    $db->query_update('nested_tree', array('title' => mysql_real_escape_string(stripslashes($_POST['newtitle']))), "id=" . $id[1]);
    //Show value
    echo $_POST['newtitle'];
} else {
    if (isset($_POST['renewal_period']) && !isset($_POST['type'])) {
        //Check if renewal period is an integer
        if (is_int(intval($_POST['renewal_period']))) {
            $id = explode('_', $_POST['id']);
            //update DB
            $db->query_update('nested_tree', array('renewal_period' => mysql_real_escape_string(stripslashes($_POST['renewal_period']))), "id=" . $id[1]);
            //Show value
            echo $_POST['renewal_period'];
        } else {
            //Show ERROR
            echo $txt['error_renawal_period_not_integer'];
        }
开发者ID:sleepy909,项目名称:cpassman,代码行数:31,代码来源:folders.queries.php

示例11: Database

<?php

require "dbase/config.inc.php";
require "dbase/Database.class.php";
$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
//parent and tutor
$user["fname"] = $_POST["user-fname"];
$user["lname"] = $_POST["user-lname"];
$user["email"] = $_POST["user-email"];
$user["city"] = $_POST["user-city"];
$user["postcode"] = $_POST["user-postcode"];
$user["state"] = $_POST["user-state"];
$user["phone"] = $_POST["user-phone"];
$id = substr($_GET["user"], 1);
$user_type = substr($_GET["user"], 0, 1);
//p or t
if ($user_type == "p") {
    $db->query_update("tblparents", $user, "id='{$id}'");
    echo "<script>\n\t             window.history.go(-1);\n\t     \t</script>";
} else {
    if ($user_type == "t") {
        $db->query_update("tbltutor", $user, "id='{$id}'");
        echo "<script>\n\t             window.history.go(-1);\n\t     \t</script>";
    } else {
        $db->query_update("tblstudents", $std, "parent_id='{$id}'");
        echo "<script>\n\t             window.history.go(-1);\n\t     \t</script>";
    }
}
开发者ID:AIMHIGHTUITION,项目名称:beta,代码行数:29,代码来源:edit_update.php

示例12: excluir

	function excluir($id)
	{
		$db = new Database();
		$sql = 'delete from periodo where id = '.$id; 
		return $db->query_update($sql);
	}
开发者ID:pauloporto,项目名称:reserva-de-salas,代码行数:6,代码来源:periodo.php

示例13: Database

<?php

require '../common/admin_session.php';
require '../common/database.php';
require '../config/config.php';
$db = new Database($db_host, $db_username, $db_password, $db_name);
$db->connect();
// For delete action
if ($_GET['action'] == "delete") {
    if ($_GET['id'] > 0) {
        $sql = "DELETE FROM " . $TABLE_EYO_MAP . " where id=" . $_GET['id'];
        $db->query($sql);
        header("Location: index.php");
        die;
    }
} else {
    if ($_GET['action'] == "update") {
        $update_array['status'] = $_GET['status'] ? 0 : 1;
        $db->query_update($TABLE_EYO_MAP, $update_array, " id=" . $_GET['id']);
        header("Location: index.php");
        die;
    }
}
header("Location: index.php");
die;
开发者ID:saifuddinsarker,项目名称:Google_Map_Ext,代码行数:25,代码来源:delete_update.php

示例14: array

 //log
 $db->query_insert('log_items', array('id_item' => $new_id, 'date' => mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('y')), 'id_user' => $_SESSION['user_id'], 'action' => 'at_creation'));
 //Add tags
 $tags = explode(' ', $_POST['tags']);
 foreach ($tags as $tag) {
     if (!empty($tag)) {
         $db->query_insert('tags', array('item_id' => $new_id, 'tag' => strtolower($tag)));
     }
 }
 // Check if any files have been added
 if (!empty($_POST['random_id_from_files'])) {
     $sql = "SELECT id\r\n                            FROM " . $pre . "files\r\n                            WHERE id_item=" . $_POST['random_id_from_files'];
     $rows = $db->fetch_all_array($sql);
     foreach ($rows as $reccord) {
         //update item_id in files table
         $db->query_update('files', array('id_item' => $new_id), "id='" . $reccord['id'] . "'");
     }
 }
 //Update CACHE table
 UpdateCacheTable("add_value", $new_id);
 //Announce by email?
 if ($_POST['annonce'] == 1) {
     require_once "class.phpmailer.php";
     //envoyer email
     $destinataire = explode(';', $_POST['diffusion']);
     foreach ($destinataire as $mail_destinataire) {
         //envoyer ay destinataire
         $mail = new PHPMailer();
         $mail->SetLanguage("en", "../includes/libraries/phpmailer/language");
         $mail->IsSMTP();
         // send via SMTP
开发者ID:omusico,项目名称:isle-web-framework,代码行数:31,代码来源:items.queries.php

示例15: COUNT

 } else {
     $manage_kb = true;
 }
 if ($manage_kb == true) {
     //Add category if new
     $data = $db->fetch_row("SELECT COUNT(*) FROM " . $pre . "kb_categories WHERE category = '" . mysql_real_escape_string($category) . "'");
     if ($data[0] == 0) {
         $cat_id = $db->query_insert("kb_categories", array('category' => mysql_real_escape_string($category)));
     } else {
         //get the ID of this existing category
         $cat_id = $db->fetch_row("SELECT id FROM " . $pre . "kb_categories WHERE category = '" . mysql_real_escape_string($category) . "'");
         $cat_id = $cat_id[0];
     }
     if (isset($id) && !empty($id)) {
         //update KB
         $new_id = $db->query_update("kb", array('label' => $label, 'description' => $description, 'author_id' => $_SESSION['user_id'], 'category_id' => $cat_id, 'anyone_can_modify' => $anyone_can_modify), "id='" . $id . "'");
     } else {
         //add new KB
         $new_id = $db->query_insert("kb", array('label' => $label, 'description' => $description, 'author_id' => $_SESSION['user_id'], 'category_id' => $cat_id, 'anyone_can_modify' => $anyone_can_modify));
     }
     //delete all associated items to this KB
     $db->query_delete("kb_items", array('kb_id' => $new_id));
     //add all items associated to this KB
     foreach (explode(',', $kb_associated_to) as $item_id) {
         $db->query_insert("kb_items", array('kb_id' => $new_id, 'item_id' => $item_id));
     }
     echo '[ { "status" : "done" } ]';
 } else {
     echo '[ { "status" : "none" } ]';
 }
 break;
开发者ID:sleepy909,项目名称:cpassman,代码行数:31,代码来源:kb.queries.php


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