dir connection in separate file

master
Matt Huntington 8 years ago
parent 99ffdc74e7
commit 61dba44d59

@ -1,6 +1,6 @@
<?php
header('Content-Type: application/json');
include __DIR__ . '/../models/person.php';
include_once __DIR__ . '/../models/person.php';
if($_REQUEST['action'] === 'index'){
echo json_encode(People::find());

@ -0,0 +1,3 @@
<?php
$dbconn = pg_connect("host=localhost dbname=phpapi");
?>

@ -1,4 +1,6 @@
<?
include_once __DIR__ . '/../database/db.php';
class Person {
public $name;
public $age;
@ -7,9 +9,9 @@ class Person {
$this->age = $age;
}
}
class People {
static function find(){
$dbconn = pg_connect("host=localhost dbname=phpapi");
$result = pg_query('SELECT * FROM people');
$people = array();
while($data = pg_fetch_object($result)){

Loading…
Cancel
Save