Похожие чаты

Hey guys. I have a MySQL question. I have two

tables: products and images with a one to many relationship (one product, many images). There's a foreign key in the images table referencing the products table primary key.

The problem is that value isn't known until the insert is made so the rows in the images table can't reference the relevant row in products table. (Worse, if the foreign key is set to not null it won't make the insert).

What's a way to circumnavigate this?

Thanks in advance.

2 ответов

13 просмотров

insert product first then you have the product key, so now you can insert the images

For starters i would not recommend using table to store images consider having a folder with your images instead save images in folder then add the folder path to your products table

Похожие вопросы

Обсуждают сегодня

Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
32
Хотел бы спросить у знающих, правильную ли я выбрал книгу для начала изучения ассемблера Юрова В.И ? Или есть более лучшие книги для начала обучения?
Botsman
25
Добрый день, не подскажите, если в OC-V3 поменять страндартную директорию /storage/ на /storage2/ - не будет сильно много проблем ?
Max Dubovsky
32
Книга Юрова В.И пойдёт для обучения?
Botsman
24
Conversation at a festival with a non-crpto person (not a normie by any stretch, though): * person: tell me about crypto, me: ok, the original idea is p2p sound money for the...
molecular#123 🐓
23
$params = [ 'formid' => 'feedbackForm', 'formTpl' => '@CODE: <form class="form-validate" data-id="ajax_form"> <fieldset class="margin-bottom-md"> ...
Pathologic
1
I bought some PHA tokens on Kucoin, which is the best wallet to store and easy to use?
AMR
19
Подскажите пожалуйста, а я могу вот такую штуку использовать? rpc, только реализованное в реббите https://www.rabbitmq.com/tutorials/tutorial-six-php ( или https://habr.com/ru...
Artyom
11
'frakturBold' => ['𝖆', '𝖇', '𝖈', '𝖉', '𝖊', '𝖋', '𝖌', '𝖍', '𝖎', '𝖏', '𝖐', '𝖑', '𝖒', '𝖓', '𝖔', '𝖕', '𝖖', '𝖗', '𝖘', '𝖙', '𝖚', '𝖛', '𝖜', '𝖝', '𝖞', '𝖟', '𝕬', '𝕭', '𝕮', '𝕯'...
Roma
4
But belive Kraken was like a few days with bank transfer and 1% or so? Obv your best option, no reason to fomo. You need to get any crypto first, then you can swap it for xmr
High CheeӃs
15
Карта сайта