Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

mongo created id

$job = new Job();
$job->title = $job_title;
if ($job->save()) {
    /* how to get id? */ 
}

Is there a way to access $id of created document without new query to a database?



1.5k
Accepted
answer

Have you tried $job->Id or $job->getId()?

you may use vardump($job) to find exactly the attribute name where you can access the id.



199

Hello

This is a example to create your mongo id https://zappysys.com/blog/ssis-loading-data-into-mongodb-upsert-update-delete-insert/

Hope This will help you.