public function getTermsDataFromThesaurus($object)
{
$connection = $this->getConnection();
$binds = [':thesaurus_id' => (int) $object->getThesaurusId()];
$select = $connection->select();
$select->from(['expansion_table' => $this->getTable(ThesaurusInterface::EXPANSION_TABLE_NAME)])->where('expansion_table.' . ThesaurusInterface::THESAURUS_ID . ' = :thesaurus_id')->group('term_id')->columns([ThesaurusInterface::THESAURUS_ID => ThesaurusInterface::THESAURUS_ID, 'term_id' => 'term_id', 'values' => new \Zend_Db_Expr("GROUP_CONCAT( expansion_table.term SEPARATOR ',')")]);
// Retrieve also reference term if needed.
if ($object->getType() === ThesaurusInterface::TYPE_EXPANSION) {
$select->joinLeft(['ref' => $this->getTable(ThesaurusInterface::REFERENCE_TABLE_NAME)], new \Zend_Db_Expr("ref.term_id = expansion_table.term_id AND ref.thesaurus_id = expansion_table.thesaurus_id"), ['reference_term' => 'term']);
}
$termsData = $connection->fetchAll($select, $binds);
return $termsData;
}