I add values into my two tables using the code below, but I also have a junction table called book_main_cover and I want to add data into this table to make a connection between book_id and metadata_image_id, how can I do it when I add the records for the first time?
With the code below, I can only add individual records without a connection.
$stmt = $sqli->prepare("INSERT INTO book(book_original_name, book_turkish_name, book_publication_date, book_synopsis) VALUES (?,?,?,?)");
$stmt->bind_param("ssss", $_POST['book_original_name'], $_POST['book_tr_name'], $_POST['book_year'], $_POST['book_synopsis']);
$stmt->execute();
$stmt->close();
$stmt = $sqli->prepare("INSERT INTO metadata_images(metadata_image_value, type, size) VALUES (?,?,?)");
$stmt->bind_param("sss", $name, $_FILES['book_cover']['type'], $_FILES['book_cover']['size']);
$stmt->execute();
$stmt->close();
I am using MySQL and InnoDB.
My database structure:
Table : book
book_id (PK)
book_original_name
book_tr_name
book_publication_date
book_synopsis
Table : metadata_images
metadata_image_id (PK)
metadata_image_value
type
size
Junction Table : book_main_cover
book_id (FK from book)
book_metadata_id (FK from metadata_images)
Aucun commentaire:
Enregistrer un commentaire