Good day,
I will be glad to get help on how I can insert into two different table once in a database using PDO with prepare statement…below is my php code…
$pdo->beginTransaction();
$sql = 'INSERT INTO members SET
first_name = :firstName,
last_name = :lastName,
user_name = :userName' ;
$s = $pdo->prepare($sql);
$s->bindValue(':firstName', $firstName);
$s->bindValue(':lastName', $lastName);
$s->bindValue(':userName', $userName);
$s->execute();
$frnd = 'INSERT INTO friends SET
friend_one = :friend_one,
friend_two = :friend_two,
status = 2';
$s = $pdo->prepare($frnd);
$s->bindValue(':friend_one', $userName);
$s->bindValue(':friend_two', $userName);
$s->execute();
$pdo->commit();
Thanks.