@ -198,16 +198,16 @@ Now let's update `controllers/people.php` to handle these requests. Add the fol
} else if ($_REQUEST['action'] === 'update'){
$request_body = file_get_contents('php://input');
$body_object = json_decode($request_body);
$updatedPerson = new Person($_REQUEST['id'], $body_object->name, $body_object->age);
$allPeople = People::update($updatedPerson);
$updated_person = new Person($_REQUEST['id'], $body_object->name, $body_object->age);
$all_people = People::update($updated_person);
echo json_encode($allPeople);
echo json_encode($all_people);
}
```
This is very similar to the create action. The only real difference is that we use `$_REQUEST['id']` to fetch the id of the person to be updated from the URL of the route. Everything else for the new `Person` object comes from the request body as normal.
Note that we're not actually creating a new `Person` object in the database, even though we have `$updatedPerson = new Person($_REQUEST['id'], $body_object->name, $body_object->age);`. Here, `$updatedPerson` is a new PHP object that resides in the computer's temporary memory, not in the DB. We're temporarily creating this PHP object so that we can pass it to `People::update()`, which will then use the properties of that PHP object to update an already pre-existing row in Postgres. Once we exit from the `else if` statement, `$updatedPerson` is destroyed in memory, since it is no longer needed.
Note that we're not actually creating a new `Person` object in the database, even though we have `$updated_person = new Person($_REQUEST['id'], $body_object->name, $body_object->age);`. Here, `$updated_person` is a new PHP object that resides in the computer's temporary memory, not in the DB. We're temporarily creating this PHP object so that we can pass it to `People::update()`, which will then use the properties of that PHP object to update an already pre-existing row in Postgres. Once we exit from the `else if` statement, `$updated_person` is destroyed in memory, since it is no longer needed.
## Delete
@ -242,8 +242,8 @@ Now let's update `controllers/people.php` to handle these requests. Add the fol