Initial
This commit is contained in:
26
Database.php
Normal file
26
Database.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: leanderschmedemann
|
||||
* Date: 02/03/2017
|
||||
* Time: 09:59
|
||||
*/
|
||||
class Database
|
||||
{
|
||||
private $db;
|
||||
|
||||
function __construct() {
|
||||
$this->db = pg_connect("host=".DATABASE_URL." dbmane=".DATABASE_NAME." user=".DATABASE_USER." password=".DATABASE_PASSWORD);
|
||||
}
|
||||
|
||||
function query($sql) {
|
||||
$result = pg_query($this->db, $sql);
|
||||
if(!$result) {
|
||||
echo json_encode(array("error"=>1));
|
||||
exit;
|
||||
}
|
||||
$arr = pg_fetch_all($result);
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
15
config.inc.php
Normal file
15
config.inc.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: leanderschmedemann
|
||||
* Date: 02/03/2017
|
||||
* Time: 09:45
|
||||
*/
|
||||
|
||||
define("DATABASE_URL", 'lamp.wlan.hwr-berlin.de');
|
||||
define("DATABASE_USER", 'gr2');
|
||||
define("DATABASE_PASSWORD", '2Au-R2n-cQN-uuG');
|
||||
define("DATABASE_NAME", 'CSDB');
|
||||
|
||||
// TODO
|
||||
?>
|
||||
14
includes.inc.php
Normal file
14
includes.inc.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: leanderschmedemann
|
||||
* Date: 02/03/2017
|
||||
* Time: 09:47
|
||||
*/
|
||||
|
||||
//include include files
|
||||
|
||||
require_once('config.inc.php');
|
||||
require_once('Database.php');
|
||||
|
||||
?>
|
||||
11
index.php
Normal file
11
index.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: leanderschmedemann
|
||||
* Date: 02/03/2017
|
||||
* Time: 09:43
|
||||
*/
|
||||
|
||||
echo "This is an API. Specs can be found at /dev/null."
|
||||
|
||||
?>
|
||||
18
register.php
Normal file
18
register.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: leanderschmedemann
|
||||
* Date: 02/03/2017
|
||||
* Time: 10:23
|
||||
*/
|
||||
|
||||
require_once('includes.inc.php');
|
||||
|
||||
$name = $_GET['name'];
|
||||
$database = new Database();
|
||||
$result = $database->query('SELECT * FROM CATEGORIES');
|
||||
|
||||
print nl2br(print_r($name, true));
|
||||
print nl2br(print_r($result, true));
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user