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


PHP GetDevicesFromGroup函数代码示例

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


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

示例1: get_devices_by_group

function get_devices_by_group()
{
    $app = \Slim\Slim::getInstance();
    $router = $app->router()->getCurrentRoute()->getParams();
    $status = 'error';
    $code = 404;
    $count = 0;
    $name = urldecode($router['name']);
    $devices = array();
    if (empty($name)) {
        $message = 'No device group name provided';
    } else {
        $group_id = dbFetchCell("SELECT `id` FROM `device_groups` WHERE `name`=?", array($name));
        $devices = GetDevicesFromGroup($group_id, true);
        $count = count($devices);
        if (empty($devices)) {
            $message = 'No devices found in group ' . $name;
        } else {
            $message = "Found {$count} in group {$name}";
            $code = 200;
        }
    }
    $output = array('status' => $status, 'message' => $message, 'count' => $count, 'devices' => $devices);
    $app->response->setStatus($code);
    $app->response->headers->set('Content-Type', 'application/json');
    echo _json_encode($output);
}
开发者ID:wiad,项目名称:librenms,代码行数:27,代码来源:api_functions.inc.php

示例2: UpdateDeviceGroup

/**
 * Update the device-group relationship for the given group id
 * @param $group_id
 */
function UpdateDeviceGroup($group_id)
{
    $queried_devices = QueryDevicesFromGroup($group_id);
    $db_devices = GetDevicesFromGroup($group_id);
    // compare the arrays to get the added and removed devices
    $added_devices = array_diff($queried_devices, $db_devices);
    $removed_devices = array_diff($db_devices, $queried_devices);
    // insert new devices
    $insert = array();
    foreach ($added_devices as $device_id) {
        $insert[] = array('device_id' => $device_id, 'device_group_id' => $group_id);
    }
    if (!empty($insert)) {
        dbBulkInsert($insert, 'device_group_device');
    }
    // remove old devices
    if (!empty($removed_devices)) {
        dbDelete('device_group_device', '`device_group_id`=? AND `device_id` IN (?)', array($group_id, array(implode(',', $removed_devices))));
    }
}
开发者ID:wiad,项目名称:librenms,代码行数:24,代码来源:device-groups.inc.php

示例3: AND

     $sql_param[] = $vars['disabled'];
 }
 if (!empty($vars['ignore'])) {
     $where .= " AND `ignore`= ?";
     $sql_param[] = $vars['ignore'];
 }
 if (!empty($vars['location']) && $vars['location'] == "Unset") {
     $location_filter = '';
 }
 if (!empty($vars['location'])) {
     $location_filter = $vars['location'];
 }
 if (!empty($vars['group'])) {
     require_once '../includes/device-groups.inc.php';
     $where .= " AND ( ";
     foreach (GetDevicesFromGroup($vars['group']) as $dev) {
         $where .= "device_id = ? OR ";
         $sql_param[] = $dev;
     }
     $where = substr($where, 0, strlen($where) - 3);
     $where .= " )";
 }
 $query = "SELECT * FROM `devices` WHERE 1 ";
 if (isset($where)) {
     $query .= $where;
 }
 $query .= " ORDER BY hostname";
 $row = 1;
 foreach (dbFetchRows($query, $sql_param) as $device) {
     if (is_integer($row / 2)) {
         $row_colour = $list_colour_a;
开发者ID:awlx,项目名称:librenms,代码行数:31,代码来源:devices.inc.php

示例4: AND

}
if (!empty($_POST['ignore'])) {
    $sql .= ' AND `ignore`= ?';
    $param[] = $_POST['ignore'];
}
if (!empty($_POST['location']) && $_POST['location'] == 'Unset') {
    $location_filter = '';
}
if (!empty($_POST['location'])) {
    $sql .= " AND `location` = ?";
    $param[] = $_POST['location'];
}
if (!empty($_POST['group'])) {
    include_once '../includes/device-groups.inc.php';
    $sql .= ' AND ( ';
    foreach (GetDevicesFromGroup($_POST['group']) as $dev) {
        $sql .= '`devices`.`device_id` = ? OR ';
        $param[] = $dev;
    }
    $sql = substr($sql, 0, strlen($sql) - 3);
    $sql .= ' )';
}
$count_sql = "SELECT COUNT(`devices`.`device_id`) {$sql}";
$total = dbFetchCell($count_sql, $param);
if (empty($total)) {
    $total = 0;
}
if (!isset($sort) || empty($sort)) {
    $sort = '`hostname` DESC';
}
$sql .= " ORDER BY {$sort}";
开发者ID:Rosiak,项目名称:librenms,代码行数:31,代码来源:devices.inc.php


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