$sql = "INSERT INTO book (bookname) values('kkkkkkkkk');
SET @bookid = LAST_INSERT_ID();
INSERT INTO paper (papername) values('hhhhhhh');
SET @paperid = LAST_INSERT_ID();
UPDATE author SET bookid = @bookid, paperid = @paperid WHERE id = 11;
SELECT @bookid as bookid, @paperid as paperid FROM DUAL;"
$stmt = $pdoConnect->prepare($sql);
$stmt->execute();
$numofnewParn =$stmt->rowCount();
if($numofnewParn>0){
$newParentDt = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($newParentDt);
}
I have set of inserts with LAST_INSERT_ID assigned to respective parameters.
Later, updating a table with the parameters.
until $stmt->execute();
is not problem.
My question is can I continue the query by adding SELECT and fetch the data like $stmt->fetch(PDO::FETCH_ASSOC)
?
or does it not make sense? if so, is there any source?
because above code does not print out.