$query = \"INSERT INTO news VALUES (NULL, :param1 , :param2 )\";
$stmt = $pdo->prepare($query);
$params = array(
\"param1\" => $p[\'title\'],
\"param
You could use PDO::lastInsertId
$last_insert_id = $pdo->lastInsertId();
Use :
$last_insert_id = $pdo->lastInsertId();
$query = "INSERT INTO news VALUES (NULL, :param1 , :param2 )";
$stmt = $pdo->prepare($query);
$params = array(
"param1" => $p['title'],
"param2" => $p['body'],
);
$data = $stmt->execute($params);
so you can do like this to get last inserted Id
$last_id = $pdo->lastInsertId();