mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-30 09:14:08 +02:00
Ldap\Connection: Add method fetchColumn()
This commit is contained in:
parent
197861efda
commit
ac7a7e6674
@ -147,6 +147,28 @@ class Connection implements Selectable
|
||||
return array_shift($row) ?: false;
|
||||
}
|
||||
|
||||
public function fetchColumn(Query $query, array $fields = null)
|
||||
{
|
||||
if ($fields === null) {
|
||||
$fields = $query->getColumns();
|
||||
}
|
||||
|
||||
$column = current($fields);
|
||||
if (! $column) {
|
||||
throw new ProgrammingError('You must request at least one attribute when fetching a single column');
|
||||
}
|
||||
|
||||
$results = $this->fetchAll($query, array($column));
|
||||
$values = array();
|
||||
foreach ($results as $row) {
|
||||
if (isset($row->$column)) {
|
||||
$values[] = $row->$column;
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public function hasDN($dn)
|
||||
{
|
||||
$this->connect();
|
||||
|
Loading…
x
Reference in New Issue
Block a user