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

Get last insert id

So how can i get the last insert id ?

$query = $this->modelsManager->executeQuery("INSERT INTO Backend\Models\AreaCategories (urlrequest,title,area) VALUES (:url:, :title:, :area:) ", [
                    'url'   => $url,
                    'title' => $this->request->getPost("title"),
                    'area'  => $this->request->getPost("area")
                ]);
edited Apr '15

Is the id of that model auto increment?

If so see this post: https://forum.phalcon.io/discussion/113/how-get-id-from-model-create-

if ($robot->save()) {
echo "The robot id is", $robot->id, '<br>';
}

Is the id of that model auto increment?

If so see this post: https://forum.phalcon.io/discussion/113/how-get-id-from-model-create-

if ($robot->save()) {
echo "The robot id is", $robot->id, '<br>';
}

the thing is that my id table is called " _ " ( yeah , a underscore ).

Perhaps set up alias in the model to get around that.