X
X
xenonhammer2020-02-03 20:43:28
PHP
xenonhammer, 2020-02-03 20:43:28

How to assign original id to duplicate when adding in MySql?

I get the data in this form
id_product
attribute - value
attribute - value

In different products, attributes can duplicate each other, in fact, when working with Opencart3, there are two problems.
5e385b36331fc957858624.jpeg
1. you need to assign id to all attributes. at the same time, the attributes of the duplicates need to be assigned the value of the original ...

2. you need to somehow add this attribute id to the table to the goods, so as not to be confused.
5e385b44704bb951022424.jpeg

I broke my head, help with ideas, does anyone have any thoughts on how to organize this with procedural php?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kikimarik, 2020-02-04
@kikimarik

Make an attribute_product table - an intermediate one, where you will store the product attribute relationship, in it id Primary Key, product_id, attribute_id (you can use a foreign key, you can not steam
it ) goods, or, at worst, a separate request. And accordingly, also for adding the behavior, so that the connection in the database is added.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question