NimmoNet NimmoNet - 6 months ago 67
PHP Question

Doctrine2 Insert and retrieve new insert ID

In Doctrine2 using some thing like:

$user = array('username' => 'example', 'passsword' => 'changeme');

$conn->insert('users', $user);

How would I then get the last ID of the user I just inserted? If it is not possible to do this then how do you gen a id so that you can the following:

$id = //something here.
$user = array('username' => 'example', 'passsword' => 'changeme', 'id' => $id);
$conn->insert('users', $user);


If you are using the ORM


if you are using the DBAL: