diff --git a/database/sql/delete.sql b/database/sql/delete.sql new file mode 100644 index 0000000..8f26040 --- /dev/null +++ b/database/sql/delete.sql @@ -0,0 +1 @@ +DELETE FROM people WHERE id = $1 diff --git a/models/person.php b/models/person.php index a0a1fba..38606c6 100644 --- a/models/person.php +++ b/models/person.php @@ -29,16 +29,11 @@ class People { return self::find(); } - static function delete($index){ - $people = array(); - $people[] = new Person('joni', 52); - $people[] = new Person('bob', 34); - $people[] = new Person('sally', 21); - $people[] = new Person('matt', 37); - - array_splice($people, $index, 1); + static function delete($id){ + $query = file_get_contents(__DIR__ . '/../database/sql/delete.sql'); + $result = pg_query_params($query, array($id)); - return $people; + return self::find(); } static function update($index, $updatedPerson){ $people = array();