/** * {@inheritdoc} */ public function getMatchingIds() { $values = $this->objAttribute->convertValuesToValueIds(explode(',', $this->value)); if (empty($values)) { return $values; } $database = $this->objAttribute->getMetaModel()->getServiceContainer()->getDatabase(); $matches = $database->prepare(sprintf('SELECT id FROM %s WHERE %s IN (%s)', $this->objAttribute->getMetaModel()->getTableName(), $this->objAttribute->getColName(), implode(',', array_fill(0, count($values), '?'))))->execute($values); return $matches->fetchEach('id'); }
/** * {@inheritdoc} */ public function convertValuesToValueIds($values) { $strColNameAlias = $this->getAliasColumn(); $strColNameId = $this->getIdColumn(); if ($strColNameId === $strColNameAlias) { return $values; } $attribute = $this->getSelectMetaModel()->getAttribute($strColNameAlias); if (!$attribute) { // If not an attribute, perform plain SQL translation. See #32, 34. return parent::convertValuesToValueIds($values); } $sanitizedValues = array(); foreach ($values as $value) { $valueIds = $attribute->searchFor($value); if ($valueIds === null) { return null; } $sanitizedValues = array_merge($valueIds, $sanitizedValues); } return array_unique($sanitizedValues); }