Skip to content

Instantly share code, notes, and snippets.

@rob1121
Last active May 16, 2018 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rob1121/4a57a81ad3408ccf11643e0c6bcf88d7 to your computer and use it in GitHub Desktop.
Save rob1121/4a57a81ad3408ccf11643e0c6bcf88d7 to your computer and use it in GitHub Desktop.
// good for insert query
//connect to db
$name = 'Rob';
$message = 'Test';
$sql = "INSERT INTO guestBook (name, message, posted) VALUES(?, ?, NOW())";
$query = $handler->prepare($sql);
$query->execute([$name, $message]);
//echo last insrted id
echo $handler->lastInsertedId();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment