/** * Multiple-fields (e.g. select or checkbox) with numberic keys are stored as CSV to improve filters. */ private function convertSerializedValues() { $t = Attribute::getTable(); $fields = array(); $attributes = Attribute::findBy(array("{$t}.multiple='1' AND {$t}.optionsSource='foreignKey'"), null); if (null !== $attributes) { /** @var Attribute $attribute */ foreach ($attributes as $attribute) { if ($attribute instanceof IsotopeAttributeWithOptions) { $fields[] = $attribute->field_name; } } } if (!empty($fields)) { /** @var \Database\Result|object $products */ $products = $this->db->execute("\n SELECT id, " . implode(', ', $fields) . "\n FROM tl_iso_product\n WHERE " . implode(" IS NOT NULL OR ", $fields) . " IS NOT NULL\n "); while ($products->next()) { $set = array(); foreach ($fields as $field) { $value = deserialize($products->{$field}); if (!empty($value) && is_array($value)) { $set[$field] = implode(',', $value); } } if (!empty($set)) { $this->db->prepare("UPDATE tl_iso_product %s WHERE id=?")->set($set)->execute($products->id); } } } }
public function run($blnInstalled) { $this->db = \Database::getInstance(); if ($blnInstalled) { $collections = $this->db->execute("SELECT uniqid, COUNT(id) AS total\n FROM tl_iso_product_collection\n WHERE uniqid IS NOT NULL\n GROUP BY uniqid\n HAVING total>1"); while ($collections->next()) { $this->db->prepare("UPDATE tl_iso_product_collection SET uniqid=NULL WHERE uniqid=?")->execute($collections->uniqid); } } }
/** * Convert iso_filterFields configuration for new cumulative filter */ private function updateCumulativeFilterFields() { if ($this->createDatabaseField('iso_cumulativeFields', 'tl_module')) { $modules = $this->db->query("SELECT id, iso_filterFields FROM tl_module WHERE type='iso_cumulativefilter'"); while ($modules->next()) { $fields = deserialize($modules->iso_filterFields); if (!empty($fields) && is_array($fields)) { $config = array(); foreach ($fields as $field) { $config[] = array('attribute' => $field, 'queryType' => 'and', 'matchCount' => 'none'); } $this->db->prepare("UPDATE tl_module SET iso_cumulativeFields=? WHERE id=?")->execute(serialize($config), $modules->id); } } } }
/** * Guard that the access is allowed. * * @param array $allowedElements The allowed elements. * @param int $contentId The content id. * * @return void * @throws AccessDeniedException When an invalid content element type is accessed. */ private function guardAllowedAccess($allowedElements, $contentId) { $actions = array('show', 'create', 'paste', 'select', 'editAll'); if (!in_array($this->input->get('act'), $actions) && $this->input->get('mode') == 'create') { $result = $this->database->prepare('SELECT type FROM tl_content WHERE id=?')->limit(1)->execute($contentId); if ($result->numRows && !in_array($result->type, $allowedElements)) { $message = sprintf('Attempt to access restricted content element "%s"', $result->type); throw new AccessDeniedException($message); } } }
/** * Perform the action. * * @param int $startSort The first sort index. * * @param int $pid The pid. * * @return void * * @SuppressWarnings(PHPMD.Superglobals) * @SuppressWarnings(PHPMD.CamelCaseVariableName) */ private function perform($startSort, $pid) { $this->loadLanguageFiles(); // Loop over all attributes now. foreach ($this->metaModel->getAttributes() as $attribute) { if (!$this->accepts($attribute)) { continue; } $attrId = $attribute->get('id'); if ($this->knowsAttribute($attribute) || !$this->input->hasValue('attribute_' . $attrId)) { continue; } $data = array_replace_recursive($this->createEmptyDataFor($attribute), array('pid' => $pid, 'sorting' => $startSort, 'tstamp' => time(), 'attr_id' => $attrId)); $startSort += 128; $query = $this->database->prepare('INSERT INTO ' . static::$table . ' %s')->set($data); $query->execute(); $data['id'] = $query->insertId; $this->knownAttributes[$attrId] = $data; } }
/** * {@inheritdoc} */ public function getMatchingIds() { $objMatches = $this->dataBase->prepare($this->strQueryString)->execute($this->arrParams); return $objMatches->numRows == 0 ? array() : $objMatches->fetchEach($this->strIdColumn); }