Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Goodnight.
Why are there multiple values in one field?
Do you just store images or are they tied to a particular entry in the database?
As an option - two tables.
In one, the name of a group of images, in the second, addresses, each under a separate id. Link tables by group id from the first table.
When writing to the database, first create a group in the first table, then write addresses to the second table and write the group id in the parent_id field.
ps Although you can get by with one table
2 options:
1 Correct:
there are two tables, for example product and product_image, pictures are stored in the second, each in a separate line, product is associated with product_image through hasMany and product_id
2 option:
yii\helpers\Json will help convert the array with image data in time , which can be written into 1 cell, and then using it to convert back to an array. You can put this logic in beforeSave and in AfterFind
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question