Схема
private mixed
attributeExists (
$groupId, $name )
Аргументы
| Аргумент |
Возможный тип |
Описание |
| $groupId |
— |
— |
| $name |
— |
— |
Описание
Метод пока еще не документирован.
Исходный код
$this->openbay->ebay->log('Checking attribute: '.$name);
$qry = $this->db->query("
SELECT * FROM
`" . DB_PREFIX . "attribute_description` `ad`,
`" . DB_PREFIX . "attribute` `a`
WHERE `ad`.`name` = '".$this->db->escape(htmlspecialchars($name, ENT_COMPAT))."'
AND `ad`.`language_id` = '".(int)$this->config->get('config_language_id')."'
AND `a`.`attribute_id` = `ad`.`attribute_id`
AND `a`.`attribute_group_id` = '".$this->db->escape($groupId)."'
LIMIT 1
");
if($qry->num_rows) {
$this->openbay->ebay->log('Attribute exists');
return $qry->row['attribute_id'];
}else{
$this->openbay->ebay->log('New attribute');
$qry2 = $this->db->query("SELECT `sort_order` FROM `" . DB_PREFIX . "attribute` ORDER BY `sort_order` DESC LIMIT 1");
if($qry2->num_rows) {
$sort = $qry2->row['sort_order'] + 1;
}else{
$sort = 0;
}
$this->db->query("INSERT INTO `" . DB_PREFIX . "attribute` SET `sort_order` = '" . (int)$sort . "', `attribute_group_id` = '" . (int)$groupId . "'");
$id = $this->db->getLastId();
$this->db->query("INSERT INTO `" . DB_PREFIX . "attribute_description` SET `attribute_id` = '" . (int)$id . "', `language_id` = '".(int)$this->config->get('config_language_id')."', `name` = '".$this->db->escape(htmlspecialchars($name, ENT_COMPAT))."'");
return (int)$id;
}