本文整理汇总了PHP中dbUpdate函数的典型用法代码示例。如果您正苦于以下问题:PHP dbUpdate函数的具体用法?PHP dbUpdate怎么用?PHP dbUpdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbUpdate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discover_wifi_radio
function discover_wifi_radio($device_id, $radio)
{
$params = array('radio_ap', 'radio_mib', 'radio_number', 'radio_type', 'radio_status', 'radio_clients', 'radio_txpower', 'radio_channel', 'radio_mac', 'radio_protection', 'radio_bsstype');
if (is_array($GLOBALS['cache']['wifi_radios'][$radio['radio_ap']][$radio['radio_number']])) {
$radio_db = $GLOBALS['cache']['wifi_radios'][$radio['radio_ap']][$radio['radio_number']];
}
if (!isset($radio_db['wifi_radio_id'])) {
$insert = array();
$insert['device_id'] = $device_id;
foreach ($params as $param) {
$insert[$param] = $radio[$param];
if ($radio[$param] == NULL) {
$insert[$param] = array('NULL');
}
}
$wifi_radio_id = dbInsert($insert, 'wifi_radios');
echo "+";
} else {
$update = array();
foreach ($params as $param) {
if ($radio[$param] != $radio_db[$param]) {
$update[$param] = $radio[$param];
}
}
if (count($update)) {
dbUpdate($update, 'wifi_radios', '`wifi_radio_id` = ?', array($radio_db['wifi_radio_id']));
echo 'U';
} else {
echo '.';
}
}
$GLOBALS['valid']['wifi']['radio'][$radio['radio_mib']][$wifi_radio_id] = 1;
// FIXME. What? How it passed there?
}
示例2: edit_service
function edit_service($update = array(), $service = null)
{
if (!is_numeric($service)) {
return false;
}
return dbUpdate($update, 'services', '`service_id`=?', array($service));
}
示例3: mergeCart
function mergeCart($usr)
{
require "mysql.php";
require "../../library/connect.php";
$conn = server_connect();
//if there are items in the cart add them to the data base
if (isset($_SESSION['cart'])) {
$cart = $_SESSION['cart'];
foreach ($cart as $item_id => $quantity) {
$query = "INSERT INTO cart (user_id, item_id, quantity) VALUES ({$usr}, {$item_id}, {$quantity}) ON DUPLICATE KEY UPDATE quantity = {$quantity} ";
dbUpdate($query);
}
}
$cart = array();
$query = "SELECT item_id, quantity FROM cart WHERE user_id = {$usr}";
$result = mysqli_query($conn, $query);
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
$cart[$row["item_id"]] = $row["quantity"];
}
$_SESSION['cart'] = $cart;
} else {
$_SESSION['log'] .= mysqli_error($conn);
}
}
示例4: thumbnailForm_submit
function thumbnailForm_submit($form, $form_state)
{
$params = drupal_get_query_parameters();
// getting the inputted info from the fields
$fields = array("FID");
$picData = getFields($fields, $form_state['values']);
$picData = stripTags($picData, '');
$oldFID = isset($form_state['oldFID']) ? $form_state['oldFID'] : 0;
if (isset($params["UID"])) {
// if updating user's profile picture
$UID = $params["UID"];
replacePicture($picData['FID'], $oldFID, 'Users');
dbUpdate("profiles", $picData, "UID", $UID);
drupal_goto("viewUser", array('query' => array('UID' => $UID)));
} else {
if (isset($params["OID"])) {
// if editing outreach thumbnail
$OID = $params["OID"];
replacePicture($picData['FID'], $oldFID, 'Outreach');
dbUpdateOutreach($OID, $picData);
drupal_goto("viewOutreach", array('query' => array('OID' => $OID)));
} else {
if (isset($params["TID"])) {
// if editing team thumbnail
$TID = $params["TID"];
replacePicture($picData['FID'], $oldFID, 'Teams');
dbUpdateTeam($TID, $picData);
drupal_goto("viewTeam", array('query' => array('TID' => $TID)));
} else {
drupal_goto("myDashboard");
}
}
}
}
示例5: loginCheck
function loginCheck()
{
$user = gpost('uname');
$pass = md5(gpost('passwd'));
$t = mysql_query("SELECT * FROM admin WHERE uname='{$uname}' AND passwd='{$passwd}'");
if (mysql_num_rows($t) == 1) {
$r = mysql_fetch_array($t);
if ($r['app'] == APID || $r['level'] == 1) {
$_SESSION[ASID . 'admin_id'] = $r['replid'];
$_SESSION[ASID . 'admin_name'] = $r['nama'];
$_SESSION[ASID . 'admin_uname'] = $r['uname'];
$_SESSION[ASID . 'admin_level'] = $r['level'];
$_SESSION[ASID . 'admin_dept'] = $r['departemen'];
$_SESSION[ASID . 'admin_pegawai'] = $r['pegawai'];
$_SESSION[ASID . 'admin_bahasa'] = $r['bahasa'];
dbUpdate("admin", array('tlogin' => date("Y-m-d H:i:s")), "replid='" . $r['replid'] . "'");
echo $r['nama'];
} else {
echo "0";
//echo $r['nama'];
}
} else {
//echo $r['nama'];
echo "0";
}
}
示例6: userStoreData
function userStoreData(&$session, $isnew, $id)
{
$session->trace(TC_Gui3, 'forum.UserStoreData');
if ($_POST['forum_postingsperpage'] <= 0) {
$_POST['forum_postingsperpage'] = 10;
}
if ($_POST['forum_threadsperpage'] <= 0) {
$_POST['forum_threadsperpage'] = 10;
}
dbUpdate($session, T_User, $id, 'postingsperpage=' . $_POST['forum_postingsperpage'] . ',threadsperpage=' . $_POST['forum_threadsperpage'] . ',');
}
示例7: EditDeviceGroup
/**
* Update a device group
* @param $group_id
* @param $pattern
* @param $name
* @param $desc
* @return bool
*/
function EditDeviceGroup($group_id, $name = null, $desc = null, $pattern = null)
{
$vars = array();
if (!is_null($name)) {
$vars['name'] = $name;
}
if (!is_null($desc)) {
$vars['desc'] = $desc;
}
if (!is_null($pattern)) {
$vars['pattern'] = $pattern;
}
$success = dbUpdate($vars, 'device_groups', 'id=?', array($group_id)) >= 0;
if ($success) {
UpdateDeviceGroup($group_id);
}
return $success;
}
示例8: main
function main()
{
if (array_key_exists("CID", $_GET)) {
$CID = $_GET["CID"];
} else {
print_r("ERROR: CID NOT FOUND");
$CID = 1;
}
if (!array_key_exists("customerForm", $_GET)) {
$data = takeCustomerFromDataBase($CID);
showCustomerForm($data, "", array());
// sends an empty array as the badFields
} else {
$badFields = customerValidate($_GET);
// checks to make sure the info given is complete
if (count($badFields) != 0) {
showCustomerForm($_GET, "", $badFields);
} else {
// at this point we have good data, and just need to get it into the
// database. Before we do it, get the OID from the form data so we
// know whether we need to go back to the orders page or customer page
$OID = NULL;
if (array_key_exists("OID", $_GET)) {
$OID = $_GET["OID"];
}
$customer = formatForDataBase($_GET);
$CID = dbUpdate("customers", $customer, "CID", $CID);
// get the configuration information from the Wordpress page so we know where
// our target "return to" pages are
$config = getConfigData();
$backToOrder = getSpecialVariable("backToOrder", $config);
$backToCustomer = getSpecialVariable("backToCustomer", $config);
if ($OID) {
// came from order
backToWPPage($backToOrder, "oid={$OID}");
} else {
// otherwise from a customer edit
backToWPPage($backToCustomer, "CID={$CID}");
}
}
}
}
示例9: process_port_adsl
function process_port_adsl(&$this_port, $device, $port)
{
// Check to make sure Port data is cached.
if (!isset($this_port['adslLineCoding'])) {
return;
}
// Used below for StatsD only
$adsl_oids = array('adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAtucChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate', 'adslAturChanCurrTxRate', 'adslAtucPerfLofs', 'adslAtucPerfLoss', 'adslAtucPerfLprs', 'adslAtucPerfESs', 'adslAtucPerfInits', 'adslAturPerfLofs', 'adslAturPerfLoss', 'adslAturPerfLprs', 'adslAturPerfESs', 'adslAtucChanCorrectedBlks', 'adslAtucChanUncorrectBlks', 'adslAturChanCorrectedBlks', 'adslAturChanUncorrectBlks');
$adsl_db_oids = array('adslLineCoding', 'adslLineType', 'adslAtucInvVendorID', 'adslAtucInvVersionNumber', 'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAtucCurrAttainableRate', 'adslAturInvSerialNumber', 'adslAturInvVendorID', 'adslAturInvVersionNumber', 'adslAtucChanCurrTxRate', 'adslAturChanCurrTxRate', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate');
$adsl_tenth_oids = array('adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr');
foreach ($adsl_tenth_oids as $oid) {
if (isset($this_port[$oid])) {
$this_port[$oid] = $this_port[$oid] / 10;
}
}
if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?", array($port['port_id'])) == "0") {
dbInsert(array('port_id' => $port['port_id']), 'ports_adsl');
}
$adsl_update = array('port_adsl_updated' => array('NOW()'));
foreach ($adsl_db_oids as $oid) {
$adsl_update[$oid] = $this_port[$oid];
}
dbUpdate($adsl_update, 'ports_adsl', '`port_id` = ?', array($port['port_id']));
if ($this_port['adslAtucCurrSnrMgn'] > "1280") {
$this_port['adslAtucCurrSnrMgn'] = "U";
}
if ($this_port['adslAturCurrSnrMgn'] > "1280") {
$this_port['adslAturCurrSnrMgn'] = "U";
}
rrdtool_update_ng($device, 'port-adsl', array('AtucCurrSnrMgn' => $this_port['adslAtucCurrSnrMgn'], 'AtucCurrAtn' => $this_port['adslAtucCurrAtn'], 'AtucCurrOutputPwr' => $this_port['adslAtucCurrOutputPwr'], 'AtucCurrAttainableR' => $this_port['adslAtucCurrAttainableR'], 'AtucChanCurrTxRate' => $this_port['adslAtucChanCurrTxRate'], 'AturCurrSnrMgn' => $this_port['adslAturCurrSnrMgn'], 'AturCurrAtn' => $this_port['adslAturCurrAtn'], 'AturCurrOutputPwr' => $this_port['adslAturCurrOutputPwr'], 'AturCurrAttainableR' => $this_port['adslAturCurrAttainableR'], 'AturChanCurrTxRate' => $this_port['adslAturChanCurrTxRate'], 'AtucPerfLofs' => $this_port['adslAtucPerfLofs'], 'AtucPerfLoss' => $this_port['adslAtucPerfLoss'], 'AtucPerfLprs' => $this_port['adslAtucPerfLprs'], 'AtucPerfESs' => $this_port['adslAtucPerfESs'], 'AtucPerfInits' => $this_port['adslAtucPerfInits'], 'AturPerfLofs' => $this_port['adslAturPerfLofs'], 'AturPerfLoss' => $this_port['adslAturPerfLoss'], 'AturPerfLprs' => $this_port['adslAturPerfLprs'], 'AturPerfESs' => $this_port['adslAturPerfESs'], 'AtucChanCorrectedBl' => $this_port['adslAtucChanCorrectedBl'], 'AtucChanUncorrectBl' => $this_port['adslAtucChanUncorrectBl'], 'AturChanCorrectedBl' => $this_port['adslAturChanCorrectedBl'], 'AturChanUncorrectBl' => $this_port['adslAturChanUncorrectBl']), get_port_rrdindex($port));
if ($GLOBALS['config']['statsd']['enable']) {
foreach ($adsl_oids as $oid) {
// Update StatsD/Carbon
StatsD::gauge(str_replace(".", "_", $device['hostname']) . '.' . 'port' . '.' . $port['ifIndex'] . '.' . $oid, $this_port[$oid]);
}
}
//echo("ADSL (".$this_port['adslLineCoding']."/".formatRates($this_port['adslAtucChanCurrTxRate'])."/".formatRates($this_port['adslAturChanCurrTxRate']).")");
}
示例10: foreach
foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device['device_id'])) as $mempool) {
echo "Mempool " . $mempool['mempool_descr'] . ": ";
$mempool_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("mempool-" . $mempool['mempool_type'] . "-" . $mempool['mempool_index'] . ".rrd");
$file = $config['install_dir'] . "/includes/polling/mempools/" . $mempool['mempool_type'] . ".inc.php";
if (is_file($file)) {
include $file;
} else {
// Do we need a generic mempool poller?
}
if ($mempool['total']) {
$percent = round($mempool['used'] / $mempool['total'] * 100, 2);
} else {
$percent = 0;
}
echo $percent . "% ";
if (!is_file($mempool_rrd)) {
rrdtool_create($mempool_rrd, "--step 300 DS:used:GAUGE:600:0:U DS:free:GAUGE:600:0:U " . $config['rrd_rra']);
}
rrdtool_update($mempool_rrd, "N:" . $mempool['used'] . ":" . $mempool['free']);
$mempool['state'] = array('mempool_used' => $mempool['used'], 'mempool_perc' => $percent, 'mempool_free' => $mempool['free'], 'mempool_total' => $mempool['total'], 'mempool_largestfree' => $mempool['largestfree'], 'mempool_lowestfree' => $mempool['lowestfree']);
if ($config['memcached']['enable']) {
if ($debug) {
print_r($mempool['state']);
}
$memcache->set('mempool-' . $mempool['mempool_id'] . '-value', $mempool['state']);
} else {
dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
}
echo "\n";
}
unset($mempool_cache);
示例11: unmute_alert
function unmute_alert()
{
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$alert_id = mres($router['id']);
$status = 'error';
$err_msg = '';
$message = '';
$code = 500;
if (is_numeric($alert_id)) {
$status = 'ok';
$code = 200;
if (dbUpdate(array('state' => 1), 'alerts', '`id` = ? LIMIT 1', array($alert_id))) {
$message = 'Alert has been unmuted';
} else {
$message = 'No alert by that ID';
}
} else {
$err_msg = 'Invalid alert has been provided';
}
$output = array('status' => $status, 'err-msg' => $err_msg, 'message' => $message);
$app->response->setStatus($code);
$app->response->headers->set('Content-Type', 'application/json');
echo _json_encode($output);
}
示例12: RunRules
/**
* Run all rules for a device
* @param int $device Device-ID
* @return void
*/
function RunRules($device)
{
global $debug;
$chk = dbFetchRow("SELECT id FROM alert_schedule WHERE alert_schedule.device_id = ? AND NOW() BETWEEN alert_schedule.start AND alert_schedule.end", array($device));
if ($chk['id'] > 0) {
return false;
}
foreach (dbFetchRows("SELECT * FROM alert_rules WHERE alert_rules.disabled = 0 && ( alert_rules.device_id = -1 || alert_rules.device_id = ? ) ORDER BY device_id,id", array($device)) as $rule) {
echo " #" . $rule['id'] . ":";
$chk = dbFetchRow("SELECT state FROM alerts WHERE rule_id = ? && device_id = ? ORDER BY id DESC LIMIT 1", array($rule['id'], $device));
$sql = GenSQL($rule['rule']);
$qry = dbFetchRows($sql, array($device));
if (sizeof($qry) > 0) {
if ($chk['state'] === "2") {
echo " SKIP ";
} elseif ($chk['state'] === "1") {
echo " NOCHG ";
} else {
$extra = gzcompress(json_encode(array('contacts' => GetContacts($qry), 'rule' => $qry)), 9);
if (dbInsert(array('state' => 1, 'device_id' => $device, 'rule_id' => $rule['id'], 'details' => $extra), 'alert_log')) {
if (!dbUpdate(array('state' => 1, 'open' => 1), 'alerts', 'device_id = ? && rule_id = ?', array($device, $rule['id']))) {
dbInsert(array('state' => 1, 'device_id' => $device, 'rule_id' => $rule['id'], 'open' => 1), 'alerts');
}
echo " ALERT ";
}
}
} else {
if ($chk['state'] === "0") {
echo " NOCHG ";
} else {
if (dbInsert(array('state' => 0, 'device_id' => $device, 'rule_id' => $rule['id']), 'alert_log')) {
if (!dbUpdate(array('state' => 0, 'open' => 1), 'alerts', 'device_id = ? && rule_id = ?', array($device, $rule['id']))) {
dbInsert(array('state' => 0, 'device_id' => $device, 'rule_id' => $rule['id'], 'open' => 1), 'alerts');
}
echo " OK ";
}
}
}
}
}
示例13: renamehost
function renamehost($id, $new, $source = 'console')
{
global $config;
// FIXME does not check if destination exists!
$host = dbFetchCell("SELECT `hostname` FROM `devices` WHERE `device_id` = ?", array($id));
if (rename($config['rrd_dir'] . "/{$host}", $config['rrd_dir'] . "/{$new}") === TRUE) {
dbUpdate(array('hostname' => $new), 'devices', 'device_id=?', array($id));
log_event("Hostname changed -> {$new} ({$source})", $id, 'system');
} else {
echo "Renaming of {$host} failed\n";
log_event("Renaming of {$host} failed", $id, 'system');
}
}
示例14: dbInsert
//db operation : add , update, delete
$q = false;
if ($opt == 'a') {
// add
$q = dbInsert($dbtable, $inp);
$y = mysql_query("SELECT * FROM admin WHERE pegawai='" . $inp['pegawai'] . "'");
// $y=mysql_query("SELECT * FROM admin WHERE pegawai='".$inp['pegawai']."'");
if (mysql_num_rows($y) == 0) {
$y = mysql_query("SELECT hrd_pegawai.nip,hrd_pegawai.nama FROM hrd_pegawai WHERE hrd_pegawai.replid='" . $inp['pegawai'] . "'");
$u = mysql_fetch_array($y);
$q = mysql_query("INSERT INTO admin SET app='gur', nama='" . $u['nama'] . "', uname='" . $u['nip'] . "', passwd='" . md5('admin') . "', pegawai='" . $inp['pegawai'] . "', level='2'");
}
} else {
if ($opt == 'u') {
// edit
$q = dbUpdate($dbtable, $inp, "replid='{$cid}'");
} else {
if ($opt == 'd') {
// delete
$t = mysql_query("SELECT pegawai FROM aka_guru WHERE replid='{$cid}'");
$r = mysql_fetch_array($t);
$q = dbDel($dbtable, "replid='{$cid}'");
$q &= dbDel("admin", "pegawai='" . $r['pegawai'] . "'");
}
}
}
$fform->notif($q);
} else {
// form process
if ($opt == 'uf' || $opt == 'df') {
// db operation for form : update , delete
示例15: scan_new_plugins
if ($_SESSION['userlevel'] >= '10') {
// Scan for new plugins and add to the database
$new_plugins = scan_new_plugins();
// Check if we have to toggle enabled / disable a particular module
$plugin_id = $_POST['plugin_id'];
$plugin_active = $_POST['plugin_active'];
if (is_numeric($plugin_id) && is_numeric($plugin_active)) {
if ($plugin_active == '0') {
$plugin_active = 1;
} elseif ($plugin_active == '1') {
$plugin_active = 0;
} else {
$plugin_active = 0;
}
if (dbUpdate(array('plugin_active' => $plugin_active), 'plugins', '`plugin_id` = ?', array($plugin_id))) {
echo '
<script type="text/javascript">
$.ajax({
url: "",
context: document.body,
success: function(s,x){
$(this).html(s);
}
});
</script>
';
}
}
//end if
?>