Browse Source

sql init

master
Robin Thoni 9 years ago
parent
commit
2af87ca3d1
1 changed files with 27 additions and 0 deletions
  1. 27
    0
      sql.php

+ 27
- 0
sql.php View File

@@ -0,0 +1,27 @@
1
+<?php
2
+require_once "misc/config.php";
3
+require_once "utils.php";
4
+
5
+function get_database()
6
+{
7
+  static $init = 0;
8
+  static $database = NULL;
9
+  if ($init == 0)
10
+  {
11
+    $init = 1;
12
+    try
13
+    {
14
+      $database = new PDO("mysql:host:$database_host;$database_port;".
15
+                          "dbname=$database_name", $database_user,
16
+                          $database_pass);
17
+    }
18
+    catch (Exception $e)
19
+    {
20
+      var_dump($e);
21
+      error(500, "Database Fail");
22
+    }
23
+  }
24
+  return $database;
25
+}
26
+
27
+?>

Loading…
Cancel
Save