PDO - get the current inserted identifier
$query = "INSERT INTO news VALUES (NULL, :param1 , :param2 )"; $stmt = $pdo->prepare($query); $params = array( "param1" => $p['title'], "param2" => $p['body'], ); $data = $stmt->execute($params); // here i would like get current inserted ID. Is possible? $id = $data->id ???? ;
How can i do this?
+6
3 answers