How do I get lastInsertId() when doing an Insert?
How do I get lastInsertId() when doing an Insert?
I am totaly new to prepared statements. What do I replace "???" with?
[code]
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO users (fN, lN, email, pass, activationCode, tC) VALUES(?, ?, ?, ?, ?, ?)";
$q = $pdo->prepare($sql);
$uId = $pdo->???->lastInsertId() ;
$q->execute(array($fN, $lN, $email, $pass, $a, $tC));
Database::disconnect();
[/code]
[code]
$pdo = Database::connect();
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO users (fN, lN, email, pass, activationCode, tC) VALUES(?, ?, ?, ?, ?, ?)";
$q = $pdo->prepare($sql);
$uId = $pdo->???->lastInsertId() ;
$q->execute(array($fN, $lN, $email, $pass, $a, $tC));
Database::disconnect();
[/code]
This discussion has been closed.
Replies
Allan