We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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.7k
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.