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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user