Propel (ORM) provides a way to save an object and retrieve it immediately using primary key. Lets say you have a student table with id as auto increment primary key. If you are saving a new student row, you wont specify the 'id' for the new student while saving. If you want to know the id of recently inserted row, you can simply use $student->getId() on the $student object which is used to insert the object.
Here is a code snippet to make things clear:
$student = new Student();
$student->setName("foo");
.....
.....
$student->save(); // This saves the new student
$id = $student->getId(); // This retrieves the id of recently inserted student row
$newStudent = StudentPeer::retrieveByPK($id); // This retrieves latest student object using id.
While doing this, make sure that in schema file, you specify autoIncrement = true for the id column.
Here is a code snippet to make things clear:
$student = new Student();
$student->setName("foo");
.....
.....
$student->save(); // This saves the new student
$id = $student->getId(); // This retrieves the id of recently inserted student row
$newStudent = StudentPeer::retrieveByPK($id); // This retrieves latest student object using id.
While doing this, make sure that in schema file, you specify autoIncrement = true for the id column.
