Bạn có thể sử dụng insert select
tuyên bố như thế này:
$db
->prepare("INSERT INTO
events (post_id, table_code, other_id, user_id, author_id, date_time )
select ?, 15, ?, ?, ?, UNIX_TIMESTAMP()
UNION ALL
select ?, 15, ?, ?, ?, UNIX_TIMESTAMP()
from (select 1) as a
where 1=?
")->execute(array($answer_id, $answer_id, $author_ques_id, $author_ques_id,
$answer_id, $answer_id, $author_ques_id, $author_ans_id,
($yourCondition?1:0) ));