QueryColumnsFromSql: use correct DB

fixes #1173
This commit is contained in:
Thomas Gelf 2017-09-12 00:26:19 +02:00
parent 9fa641b27c
commit c27fd86f4c
1 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,7 @@
namespace Icinga\Module\Director\Web\Form\Filter;
use Exception;
use Icinga\Data\Db\DbConnection;
use Icinga\Module\Director\Forms\ImportSourceForm;
use Zend_Filter_Interface;
@ -36,8 +37,12 @@ class QueryColumnsFromSql implements Zend_Filter_Interface
protected function getQueryColumns($query)
{
return array_keys((array) current(
$this->form->getDb()->getDbAdapter()->fetchAll($query)
));
$resourceName = $this->form->getSentOrObjectSetting('resource');
if (! $resourceName) {
return [];
}
$db = DbConnection::fromResourceName($resourceName)->getDbAdapter();
return array_keys((array) current($db->fetchAll($query)));
}
}