summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/inc/rebootqueries.inc.php
blob: c0c479bd4d4cc2f1323e659b5772b2b05a332d58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php

class RebootQueries
{

	/**
	 * Get machines by list of UUIDs
	 * @param string[] $list list of system UUIDs
	 * @return array list of machines with machineuuid, hostname, clientip, state and locationid
	 */
	public static function getMachinesByUuid($list, $assoc = false, $columns = ['machineuuid', 'hostname', 'clientip', 'state', 'locationid'])
	{
		if (empty($list))
			return array();
		if (is_array($columns)) {
			$columns = implode(',', $columns);
		}
		$res = Database::simpleQuery("SELECT $columns FROM machine
				WHERE machineuuid IN (:list)", compact('list'));
		if (!$assoc)
			return $res->fetchAll(PDO::FETCH_ASSOC);
		$ret = [];
		while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
			$ret[$row['machineuuid']] = $row;
		}
		return $ret;
	}

}