[CakePHP] Getting The Last ID

Saturday, May 28, 2011 0 Comments

Getting the last Id by using Cake PHP

Statistic Information :
CakePHP : 1.3.8

In the beginning, I got some difficulties how to get the last ID in CakePHP. I thought in the book CakePHP I've downloaded, there isn't any guide or explanation. Hmm.. so? I was googling and I found how to get it. Keep reading.

It just simple enough. Just use this syntax :
$this->ModelName->getLastInsertID();
Or, you might use this one :
$this->ModelName->getInsertID();
That's it. Easy enough, isn't it? Noticed in /cake/libs/model/model.php file. You maybe got another some useful keywords.

So, what are you waiting for? Just get back to your code already! :)

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Do you think I forgot to change this text? No, dude. I did it on purpose ahahahay..