本文整理汇总了PHP中dbDelete函数的典型用法代码示例。如果您正苦于以下问题:PHP dbDelete函数的具体用法?PHP dbDelete怎么用?PHP dbDelete使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dbDelete函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete_service
function delete_service($service = null)
{
if (!is_numeric($service)) {
return false;
}
return dbDelete('services', '`service_id` = ?', array($service));
}
示例2: deluser
function deluser($username)
{
dbDelete('bill_perms', '`user_name` = ?', array($username));
dbDelete('devices_perms', '`user_name` = ?', array($username));
dbDelete('ports_perms', '`user_name` = ?', array($username));
dbDelete('users_prefs', '`user_name` = ?', array($username));
dbDelete('users', '`user_name` = ?', array($username));
return dbDelete('users', '`username` = ?', array($username));
}
示例3: delete_rule
function delete_rule()
{
global $config;
$app = \Slim\Slim::getInstance();
$router = $app->router()->getCurrentRoute()->getParams();
$rule_id = mres($router['id']);
$status = 'error';
$err_msg = '';
$message = '';
$code = 500;
if (is_numeric($rule_id)) {
$status = 'ok';
$code = 200;
if (dbDelete('alert_rules', '`id` = ? LIMIT 1', array($rule_id))) {
$message = 'Alert rule has been removed';
} else {
$message = 'No alert rule by that ID';
}
} else {
$err_msg = 'Invalid rule id 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);
}
示例4: delete_device
function delete_device($id)
{
global $config, $debug;
$ret = '';
$host = dbFetchCell("SELECT hostname FROM devices WHERE device_id = ?", array($id));
if (empty($host)) {
return "No such host.";
}
// Remove IPv4/IPv6 addresses before removing ports as they depend on port_id
dbQuery("DELETE `ipv4_addresses` FROM `ipv4_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv4_addresses`.`port_id` WHERE `device_id`=?", array($id));
dbQuery("DELETE `ipv6_addresses` FROM `ipv6_addresses` INNER JOIN `ports` ON `ports`.`port_id`=`ipv6_addresses`.`port_id` WHERE `device_id`=?", array($id));
foreach (dbFetch("SELECT * FROM `ports` WHERE `device_id` = ?", array($id)) as $int_data) {
$int_if = $int_data['ifDescr'];
$int_id = $int_data['port_id'];
delete_port($int_id);
$ret .= "Removed interface {$int_id} ({$int_if})\n";
}
$fields = array('device_id', 'host');
foreach ($fields as $field) {
foreach (dbFetch("SELECT table_name FROM information_schema.columns WHERE table_schema = ? AND column_name = ?", array($config['db_name'], $field)) as $table) {
$table = $table['table_name'];
$entries = (int) dbDelete($table, "`{$field}` = ?", array($id));
if ($entries > 0 && $debug === true) {
$ret .= "{$field}@{$table} = #{$entries}\n";
}
}
}
$ex = shell_exec("bash -c '( [ ! -d " . trim($config['rrd_dir']) . "/" . $host . " ] || rm -vrf " . trim($config['rrd_dir']) . "/" . $host . " 2>&1 ) && echo -n OK'");
$tmp = explode("\n", $ex);
if ($tmp[sizeof($tmp) - 1] != "OK") {
$ret .= "Could not remove files:\n{$ex}\n";
}
$ret .= "Removed device {$host}\n";
return $ret;
}
示例5: dbDelete
<?php
$updated = '1';
$affected = dbDelete('services', '`service_id` = ?', array($_POST['service']));
if ($affected) {
$message .= $message_break . $rows . " service deleted!";
$message_break .= "<br />";
}
示例6: str_pad
echo str_pad("dot1d id", 10) . str_pad("ifIndex", 10) . str_pad("Port Name", 25) . str_pad("Priority", 10) . str_pad("State", 15) . str_pad("Cost", 10) . "\n";
}
foreach ($vlan_data as $vlan_port_id => $vlan_port) {
$port = get_port_by_index_cache($device, $vlan_port['dot1dBasePortIfIndex']);
echo str_pad($vlan_port_id, 10) . str_pad($vlan_port['dot1dBasePortIfIndex'], 10) . str_pad($port['ifDescr'], 25) . str_pad($vlan_port['dot1dStpPortPriority'], 10) . str_pad($vlan_port['dot1dStpPortState'], 15) . str_pad($vlan_port['dot1dStpPortPathCost'], 10);
$db_w = array('device_id' => $device['device_id'], 'port_id' => $port['port_id'], 'vlan' => $vlan_id);
$db_a['baseport'] = $vlan_port_id;
$db_a['priority'] = isset($vlan_port['dot1dStpPortPriority']) ? $vlan_port['dot1dStpPortPriority'] : 0;
$db_a['state'] = isset($vlan_port['dot1dStpPortState']) ? $vlan_port['dot1dStpPortState'] : "unknown";
$db_a['cost'] = isset($vlan_port['dot1dStpPortPathCost']) ? $vlan_port['dot1dStpPortPathCost'] : 0;
$from_db = dbFetchRow("SELECT * FROM `ports_vlans` WHERE device_id = ? AND port_id = ? AND `vlan` = ?", array($device['device_id'], $port['port_id'], $vlan_id));
if ($from_db['port_vlan_id']) {
dbUpdate($db_a, 'ports_vlans', "`port_vlan_id` = ?", array($from_db['port_vlan_id']));
echo "Updated";
} else {
dbInsert(array_merge($db_w, $db_a), 'ports_vlans');
echo "Inserted";
}
echo "\n";
}
}
}
}
foreach ($vlans_db as $domain_id => $vlans) {
foreach ($vlans as $vlan_id => $vlan) {
if (empty($device['vlans'][$domain_id][$vlan_id])) {
dbDelete('vlans', "`device_id` = ? AND vlan_domain = ? AND vlan_vlan = ?", array($device['device_id'], $domain_id, $vlan_id));
}
}
}
unset($device['vlans']);
示例7: array
if ($port_low['ifType'] == 'propVirtual') {
continue;
}
//Skip stacking on Vlan ports (F.u. Cisco SB)
$ifStackStatus = $entry_low['ifStackStatus'];
if (isset($stack_db_array[$port_id_high][$port_id_low])) {
if ($stack_db_array[$port_id_high][$port_id_low]['ifStackStatus'] == $ifStackStatus) {
echo ".";
} else {
$update_array = array('ifStackStatus' => $ifStackStatus);
dbUpdate($update_array, 'ports_stack', "`device_id` = ? AND `port_id_high` = ? AND `port_id_low` = ?", array($device['device_id'], $port_id_high, $port_id_low));
echo "U";
}
unset($stack_db_array[$port_id_high][$port_id_low]);
} else {
$update_array = array('device_id' => $device['device_id'], 'port_id_high' => $port_id_high, 'port_id_low' => $port_id_low, 'ifStackStatus' => $ifStackStatus);
dbInsert($update_array, 'ports_stack');
echo "+";
}
}
}
foreach ($stack_db_array as $port_id_high => $array) {
foreach ($array as $port_id_low => $blah) {
print_debug("DELETE STACK: " . $device['device_id'] . " " . $port_id_low . " " . $port_id_high);
dbDelete('ports_stack', "`device_id` = ? AND port_id_high = ? AND port_id_low = ?", array($device['device_id'], $port_id_high, $port_id_low));
echo "-";
}
}
unset($update_array);
echo "\n";
// EOF
示例8: substr
if ($stp_raw[$port]['dot1dStpPortDesignatedPort']) {
$dp = $stp_raw[$port]['dot1dStpPortDesignatedPort'] - $dp_value;
$stp_port['designatedPort'] = $dp;
}
} else {
// Port saved in format priority+port (ieee 802.1d-1998: clause 8.5.5.1)
$dp = substr($stp_raw[$port]['dot1dStpPortDesignatedPort'], -2);
//discard the first octet (priority part)
$stp_port['designatedPort'] = hexdec($dp);
}
d_echo($stp_port);
// Write to db
if (!dbFetchCell('SELECT 1 FROM `ports_stp` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $stp_port['port_id']))) {
dbInsert($stp_port, 'ports_stp');
echo '+';
}
}
}
// Delete STP ports from db if absent in SNMP query
$stp_port_db = dbFetchRows('SELECT * FROM `ports_stp` WHERE `device_id` = ?', array($device['device_id']));
//d_echo($stp_port_db);
foreach ($stp_port_db as $port => $value) {
$if_index = dbFetchCell('SELECT `ifIndex` FROM `ports` WHERE `device_id` = ? AND `port_id` = ?', array($device['device_id'], $value['port_id']));
if ($if_index != $stp_raw[$if_index]['dot1dStpPort']) {
dbDelete('ports_stp', '`device_id` = ? AND `port_id` = ?', array($device['device_id'], $value['port_id']));
echo '-';
}
}
}
unset($stp_raw, $stp, $stp_db, $stp_port, $stp_port_db);
echo "\n";
示例9: dbUpdate
$cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop'];
$cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt'];
$cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host'];
$cef_stat['update']['drop_prev'] = $cef_entry['drop'];
$cef_stat['update']['punt_prev'] = $cef_entry['punt'];
$cef_stat['update']['punt2host_prev'] = $cef_entry['punt2host'];
$cef_stat['update']['updated'] = $polled;
$cef_stat['update']['updated_prev'] = $cef_entry['updated'];
dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path));
$fields = array('drop' => $cef_stat['cefSwitchingDrop'], 'punt' => $cef_stat['cefSwitchingPunt'], 'hostpunt' => $cef_stat['cefSwitchingPunt2Host']);
$ret = rrdtool_update("{$filename}", $fields);
$tags = array('entity' => $entity, 'afi' => $afi, 'index' => $path);
influx_update($device, 'cefswitching', $tags, $fields);
echo "\n";
}
//end foreach
}
//end foreach
}
//end foreach
}
//end if
// FIXME - need to delete old ones. FIXME REALLY.
print_r($cefs_db);
foreach ($cefs_db as $cef_switching_id) {
dbDelete('cef_switching', '`cef_switching_id` = ?', array($cef_switching_id));
echo '-';
}
echo "\n";
}
//end if
示例10: dbUpdate
// Already present in DB, update row
if (serialize($value) != $in_db[$key]) {
// Submitted value is different from current value
dbUpdate(array('config_value' => serialize($value)), 'config', '`config_key` = ?', array($key));
$updates++;
}
} else {
// Not set in DB yet, insert row
dbInsert(array('config_key' => $key, 'config_value' => serialize($value)), 'config');
$updates++;
}
}
}
// Delete fields that were reset to default
if (count($deletes)) {
dbDelete('config', '`config_key` IN (' . implode(',', $deletes) . ')');
$updates++;
}
// Print errors from validation above, if any
foreach ($errors as $error) {
print_error($error);
}
if ($updates) {
print_success("Settings updated.<br />Please note Web UI setting takes effect only when refreshing the page <i>after</i> saving the configuration. Please click <a href=\"" . $_SERVER['REQUEST_URI'] . "\">here</a> to reload the page.");
// Reload $config now, or form below will show old settings still
include $config['install_dir'] . '/includes/sql-config.inc.php';
} else {
print_error('No changes made.');
}
}
$link_array = array('page' => 'settings');
示例11: JOIN
$months = $config['billing_data_purge'];
echo "Deleting billing data more than {$months} month before the last completed billing cycle\n";
$sql = "DELETE bill_data\n FROM bill_data\n INNER JOIN (SELECT bill_id, \n SUBDATE(\n SUBDATE(\n ADDDATE(\n subdate(curdate(), (day(curdate())-1)), # Start of this month\n bill_day - 1), # Billing anniversary\n INTERVAL IF(bill_day > DAY(curdate()), 1, 0) MONTH), # Deal with anniversary not yet happened this month\n INTERVAL ? MONTH) AS threshold # Adjust based on config threshold\n FROM bills) q\n ON bill_data.bill_id = q.bill_id AND bill_data.timestamp < q.threshold;";
dbQuery($sql, array($months));
}
}
if ($options['f'] === 'alert_log') {
if (is_numeric($config['alert_log_purge']) && $config['alert_log_purge'] > 0) {
if (dbDelete('alert_log', 'time_logged < DATE_SUB(NOW(),INTERVAL ? DAY)', array($config['alert_log_purge']))) {
echo 'Alert log data cleared for entries over ' . $config['alert_log_purge'] . " days\n";
}
}
}
if ($options['f'] === 'purgeusers') {
$purge = 0;
if (is_numeric($config['radius']['users_purge']) && $config['auth_mechanism'] === 'radius') {
$purge = $config['radius']['users_purge'];
}
if (is_numeric($config['active_directory']['users_purge']) && $config['auth_mechanism'] === 'active_directory') {
$purge = $config['active_directory']['users_purge'];
}
if ($purge > 0) {
foreach (dbFetchRows("SELECT DISTINCT(`user`) FROM `authlog` WHERE `datetime` >= DATE_SUB(NOW(), INTERVAL ? DAY)", array($purge)) as $user) {
$users[] = $user['user'];
}
$del_users = '"' . implode('","', $users) . '"';
if (dbDelete('users', "username NOT IN ({$del_users})", array($del_users))) {
echo "Removed users that haven't logged in for {$purge} days";
}
}
}
示例12: foreach
echo '+';
// FIXME eventlog
} else {
echo '.';
}
/*
* Save the discovered Virtual Machine.
*/
$vmw_vmlist[] = $index;
}
/*
* Get a list of all the known Virtual Machines for this host.
*/
$sql = "SELECT id, vmwVmVMID, vmwVmDisplayName FROM vminfo WHERE device_id = '" . $device['device_id'] . "' AND vm_type='vmware'";
foreach (dbFetchRows($sql) as $db_vm) {
/*
* Delete the Virtual Machines that are removed from the host.
*/
if (!in_array($db_vm['vmwVmVMID'], $vmw_vmlist)) {
dbDelete('vminfo', '`id` = ?', array($db_vm['id']));
log_event(mres($db_vm['vmwVmDisplayName']) . ' Removed', $device, 'system', $db_vm['vmwVmVMID']);
echo '-';
// FIXME eventlog
}
}
/*
* Finished discovering VMware information.
*/
echo "\n";
}
//end if
示例13: dbDelete
if (!$af_list[$afi][$safi] || !$af_list[$entry['bgpPeerIdentifier']][$afi][$safi]) {
dbDelete('bgpPeers_cbgp', '`device_id` = ? AND `bgpPeerIdentifier` = ?, afi=?, safi=?', array($device['device_id'], $peer['ip'], $afi, $safi));
}
}
}
}
unset($j_afisafi);
unset($j_prefixes);
unset($j_bgp);
unset($j_peerIndexes);
}
// Delete removed peers
$sql = "SELECT * FROM bgpPeers AS B, devices AS D WHERE B.device_id = D.device_id AND D.device_id = '" . $device['device_id'] . "'";
foreach (dbFetchRows($sql) as $entry) {
unset($exists);
$i = 0;
while ($i < count($peerlist) && !isset($exists)) {
if ($peerlist[$i]['ip'] == $entry['bgpPeerIdentifier']) {
$exists = 1;
}
$i++;
}
if (!isset($exists)) {
dbDelete('bgpPeers', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
dbDelete('bgpPeers_cbgp', '`bgpPeer_id` = ?', array($entry['bgpPeer_id']));
echo '-';
}
}
unset($peerlist);
echo "\n";
}
示例14: snmp_hexstring
} else {
//normal devices returning toner values
$current = $current / $capacity * 100;
}
$type = 'jetdirect';
if (isHexString($descr)) {
$descr = snmp_hexstring($descr);
}
discover_toner($valid_toner, $device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current);
}
}
}
//end if
}
//end foreach
}
//end if
// Delete removed toners
d_echo("\n Checking ... \n");
d_echo($valid_toner);
$sql = "SELECT * FROM toner WHERE device_id = '" . $device['device_id'] . "'";
foreach (dbFetchRows($sql) as $test_toner) {
$toner_index = $test_toner['toner_index'];
$toner_type = $test_toner['toner_type'];
if (!$valid_toner[$toner_type][$toner_index]) {
echo '-';
dbDelete('toner', '`toner_id` = ?', array($test_toner['toner_id']));
}
}
unset($valid_toner);
echo "\n";
示例15: print_message
print_message("密码已更改.");
} else {
print_error("密码不匹配!");
}
}
// FIXME broken PoS code.
if ($vars['action'] == "becomeuser") {
$_SESSION['origusername'] = $_SESSION['username'];
$_SESSION['username'] = $user_data['username'];
header('位置: ' . $config['base_url']);
dbInsert(array('user' => $_SESSION['origusername'], 'address' => $_SERVER["REMOTE_ADDR"], 'result' => '成为 ' . $_SESSION['username']), 'authlog');
include "includes/authenticate.inc.php";
}
if ($vars['action'] == "perm_del") {
if (dbFetchCell("SELECT COUNT(*) FROM `entity_permissions` WHERE `entity_type` = ? AND `entity_id` = ? AND `user_id` = ?", array($vars['entity_type'], $vars['entity_id'], $vars['user_id']))) {
dbDelete('entity_permissions', "`entity_type` = ? AND `entity_id` = ? AND `user_id` = ?", array($vars['entity_type'], $vars['entity_id'], $vars['user_id']));
}
}
if ($vars['action'] == "perm_add") {
if (!is_array($vars['entity_id'])) {
$vars['entity_id'] = array($vars['entity_id']);
}
foreach ($vars['entity_id'] as $entry) {
if (!dbFetchCell("SELECT COUNT(*) FROM `entity_permissions` WHERE `entity_type` = ? AND `entity_id` = ? AND `user_id` = ?", array($vars['entity_type'], $entry, $vars['user_id']))) {
dbInsert(array('entity_id' => $entry, 'entity_type' => $vars['entity_type'], 'user_id' => $vars['user_id']), 'entity_permissions');
}
}
}
?>
<div class="row">