При получении getLastId() из другой функции первое значение у меня выходит NULL !! К примеру вот в данной функции я передаю в переменную полученный id
public function addProductRelated(&$product_id_related, &$dataRelated) {
$sql = '';
if(isset($this->field_caption['_MODEL-RELATED_'])) {
$sql .= ' model = \'' . $this->db->escape($dataRelated[$this->field_caption['_MODEL-RELATED_']]) .'\',';
}
$sql .= ' location = \'' . (string)$this->setting['location'] . '\',';
$sql .= ' subtract = \'' . (int)$this->setting['subtract'] . '\',';
$sql .= ' shipping = \'' . (int)$this->setting['shipping'] . '\',';
$sql .= ' date_added = NOW(),';
$sql .= ' date_available = NOW(),';
if ( isset($this->field_caption['_STATUS_']) ) {
$sql .= ' status = \'' . (int)$dataRelated[$this->field_caption['_STATUS_']] . '\',';
} else {
$sql .= ' status = \'' . (int)$this->setting['status'] . '\',';
}
if( isset($this->CustomFields[DB_PREFIX . 'product']) && count($this->CustomFields[DB_PREFIX . 'product']) > 0 ) {
foreach ($this->CustomFields[DB_PREFIX . 'product'] as $field) {
if(isset($this->field_caption[$field['csv_name']])) $sql .= ' ' . $field['field_name'] . ' = \'' . $this->db->escape($dataRelated[$this->field_caption[$field['csv_name']]]) . '\',';
}
}
if(isset($this->field_caption['_MANUFACTURER-RELATED_'])) {
$manufacturer_id = $this->getManufacturer($dataRelated[$this->field_caption['_MANUFACTURER-RELATED_']]);
$sql .= ' manufacturer_id = \'' . (int)$manufacturer_id . '\'';
} else {
$sql .= ' manufacturer_id = \'' . (int)$this->setting['product_manufacturer'] . '\''; // Last Field
}
$sql = ' INSERT INTO `product` SET ' . $sql;
$this->db->query($sql);
$product_id_related = $this->db->getLastId();
if (isset($this->setting['product_store'])) {
foreach ($this->setting['product_store'] as $store_id) {
$this->db->query('INSERT INTO `' . DB_PREFIX . 'product_to_store` SET product_id = \'' . (int)$product_id_related . '\', store_id = \'' . (int)$store_id . '\'');
}
}
if(!$product_id_related) return FALSE;
$sql = '';
if(isset($this->field_caption['_NAME-RELATED_'])) {
$sql .= ' name = REPLACE(\'' . $this->db->escape($dataRelated[$this->field_caption['_NAME-RELATED_']]) . '\', \'"\', \'"\'),';
}
if(isset($this->field_caption['_HTML_TITLE_'])) $sql .= ' seo_title = \'' . $this->db->escape($dataRelated[$this->field_caption['_HTML_TITLE_']]) . '\',';
if(isset($this->field_caption['_HTML_H1_'])) $sql .= ' seo_h1 = \'' . $this->db->escape($dataRelated[$this->field_caption['_HTML_H1_']]) . '\',';
if(isset($this->field_caption['_META_KEYWORDS_'])) $sql .= ' meta_keyword = \'' . $this->db->escape($dataRelated[$this->field_caption['_META_KEYWORDS_']]) . '\',';
if(isset($this->field_caption['_META_DESCRIPTION_'])) $sql .= ' meta_description = \'' . $this->db->escape($dataRelated[$this->field_caption['_META_DESCRIPTION_']]) . '\',';
if(isset($this->field_caption['_DESCRIPTION_'])) {
$sql .= ' description = \'' . $this->db->escape(htmlspecialchars($dataRelated[$this->field_caption['_DESCRIPTION_']])) . '\',';
}
if(in_array(VERSION, array('1.5.4', '1.5.4.1', '1.5.5', '1.5.5.1'))){
if(isset($this->field_caption['_PRODUCT_TAG_'])) $sql .= ' tag = \'' . $this->db->escape(htmlspecialchars($dataRelated[$this->field_caption['_PRODUCT_TAG_']])) . '\',';
}
if( isset($this->CustomFields[DB_PREFIX . 'product_description']) && count($this->CustomFields[DB_PREFIX . 'product_description']) > 0 ) {
foreach ($this->CustomFields[DB_PREFIX . 'product_description'] as $field) {
if(isset($this->field_caption[$field['csv_name']])) $sql .= ' ' . $field['field_name'] . ' = \'' . $this->db->escape( htmlspecialchars($dataRelated[$this->field_caption[$field['csv_name']]]) ) . '\',';
}
}
if(!empty($sql)) {
$sql = 'INSERT INTO `' . DB_PREFIX . 'product_description` SET ' . $sql . ' product_id = \'' . (int)$product_id_related . '\', language_id = \'' . (int)$this->setting['language_id'] . '\'';
$this->db->query($sql);
}
if(in_array(VERSION, array('1.5.1.3', '1.5.1.3.1', '1.5.2', '1.5.2.1', '1.5.3', '1.5.3.1'))){
if(isset($this->field_caption['_PRODUCT_TAG_'])) {
$this->db->query('DELETE FROM `' . DB_PREFIX . 'product_tag` WHERE product_id = \'' . (int)$product_id_related . '\' AND language_id = \'' . (int)$this->setting['language_id'] . '\'');
if( !empty($dataRelated[$this->field_caption['_PRODUCT_TAG_']]) ) {
$tags = explode(',', $dataRelated[$this->field_caption['_PRODUCT_TAG_']]);
foreach ($tags as $tag) {
$sql = 'INSERT INTO `' . DB_PREFIX . 'product_tag` SET product_id = \'' . (int)$product_id_related . '\', language_id = \'' . (int)$this->setting['language_id'] . '\', tag = \'' . $this->db->escape(trim($tag)) . '\'';
$this->db->query($sql);
}
}
}
}
$sql = '';
if(isset($this->field_caption['_SEO_KEYWORD_'])) {
$this->db->query('DELETE FROM `' . DB_PREFIX . 'url_alias` WHERE query = \'product_id=' . (int)$product_id_related . '\'');
if( !empty($dataRelated[$this->field_caption['_SEO_KEYWORD_']]) ) {
$sql = 'INSERT INTO `' . DB_PREFIX . 'url_alias` SET query = \'product_id=' . (int)$product_id_related . '\', keyword = \'' . $this->db->escape($dataRelated[$this->field_caption['_SEO_KEYWORD_']]) . '\'';
$this->db->query($sql);
}
}
$this->db->query('INSERT INTO `' . DB_PREFIX . 'product_to_category` SET product_id = \'' . (int)$product_id_related . '\', category_id = \'108\'');
$this->db->query("INSERT INTO url_alias
SET query = 'product_id=" . (int)$product_id_related . "',
keyword = '" . $this->db->escape($dataRelated[$this->field_caption['_MANUFACTURER-RELATED_']]. "-" .$dataRelated[$this->field_caption['_MODEL-RELATED_']]) . "'
");
$this->product_id_related_new = $product_id_related;
return true;
}
B и вывожу его в другой функции !
$get_product_id_related = $this->product_id_related_new;
echo "<pre>";
var_dump($get_product_id_related);
echo "</pre>";
и получаю результат !
Первое значение у меня NULL Но если я буду выводить данный getLastId() в самой функции то проблем у меня нет !
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Перевод документов на английский язык: Важность и ключевые аспекты
каким образом можно запустить сервер node если на странице сделать кнопку или по нажатию на dom элемент
Почему не запускается 2 процесса ? а только одинЧто я делаю не так ?
Есть такой дизайн: Как видите нужно вывести категории таким образом: