update location id

master
Matt Huntington 8 years ago
parent fae323eba8
commit fa0a9950cf

@ -18,7 +18,7 @@ if($_REQUEST['action'] === 'index'){
} else if ($_REQUEST['action'] === 'update'){
$requestBody = file_get_contents('php://input');
$body = json_decode($requestBody);
$updatedPerson = new Person(null, $body->name, $body->age);
$updatedPerson = new Person(null, $body->name, $body->age, $body->location_id);
$allPeople = People::update($_REQUEST['id'], $updatedPerson);
echo json_encode($allPeople);

@ -1 +1 @@
UPDATE people SET name = $1, age = $2 WHERE id = $3
UPDATE people SET name = $1, age = $2, location_id = $3 WHERE id = $4

@ -57,7 +57,7 @@ class People {
}
static function update($id, $updatedPerson){
$query = file_get_contents(__DIR__ . '/../database/sql/people/update.sql');
$result = pg_query_params($query, array($updatedPerson->name, $updatedPerson->age, $id));
$result = pg_query_params($query, array($updatedPerson->name, $updatedPerson->age, $updatedPerson->location_id, $id));
return self::find();
}

Loading…
Cancel
Save