Initial Commit
This commit is contained in:
commit
3f82c916ea
2
configs/.htaccess
Normal file
2
configs/.htaccess
Normal file
@ -0,0 +1,2 @@
|
||||
DENY FROM ALL
|
||||
ALLOW FROM 127.0.0.1
|
||||
15
configs/database.php
Normal file
15
configs/database.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
function openConnection() {
|
||||
$dataAccess = parse_ini_file("phpCourse/configs/db.ini", true);
|
||||
|
||||
$db = new PDO("mysql:host=" . $dataAccess["ZEDAT"]["host"] .
|
||||
";dbname=" . $dataAccess["ZEDAT"]["database"] . ";charset=utf8",
|
||||
$dataAccess["ZEDAT"]["user"], $dataAccess["ZEDAT"]["passwd"],
|
||||
array(PDO::ATTR_PERSISTENT => false));
|
||||
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
|
||||
return $db;
|
||||
}
|
||||
?>
|
||||
5
configs/db.ini
Normal file
5
configs/db.ini
Normal file
@ -0,0 +1,5 @@
|
||||
[ZEDAT]
|
||||
host = usersql.zedat.fu-berlin.de
|
||||
user = khofmann-sql
|
||||
passwd = xz8c7m7p
|
||||
database = khofmann-db1
|
||||
16
configs/index.php
Normal file
16
configs/index.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
include_once 'database.php';
|
||||
|
||||
ini_set(display_errors, 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$db = openConnection();
|
||||
|
||||
$query = "SELECT * FROM users";
|
||||
|
||||
$stmt = $db->prepare($query);
|
||||
$stmt->execute();
|
||||
$result = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
echo json_encode($result);
|
||||
?>
|
||||
Loading…
x
Reference in New Issue
Block a user