In the cakephp blog tutorial in the Edit Post edit() action section
http://book.cakephp.org/2.0/en/tutorials-and-examples/blog/part-two.html
I can't understand what this code does $this->Post->id = $id;
Your url would be something like /posts/edit/1
, where $id = 1
in this case. What that line does is set the id for the current record that the Post->save() call will affect.
What this code does is set the value of the Post id to the $id parameter, passed in the URL. The Post instance is then saved with the data entered through the form. This code is executed when the page is called on form submission.
It might be easier to understand with an example. Let's say you get the page to edit post number 3, /posts/edit/3. You fill out the form and submit. The same URL is accessed, but by POST this time. The controller now has all the data entered through the form. All it needs is the post id, which it gets from the parameter, $id. With all that, we can now save the post to the DB.