Im trying to build a form to allow binding of keywords to articles. This SQL statement works directly as a query but I dont know how to package it as a pdo statement. It adds the keyword to a Keyword Table and Keyword ID + Article ID to a many to many mapping table.
$insertK = $dbh->prepare("INSERT IGNORE INTO Keywords (Keyword)
VALUES (:KeywordID1);
INSERT INTO Keyword_Article (KeywordID, ArticleID)
VALUES ((SELECT KeywordID FROM Keywords WHERE Keyword = :KeywordID2), :ArticleID)");
$insertK->bindParam(':KeywordID1', $keywordID);
$insertK->bindParam(':KeywordID2', $keywordID);
$insertK->bindParam(':ArticleID', $articleID);
$insertK->excecute();
Ive seen PDO inserts a few different ways but none that do two statements into two different tables.
EDIT* If its not possible then how could I make sure that the first insert is finished before running the second query?