Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class DB{
- public static $host;
- public static $user;
- public static $password;
- public static $database;
- public static $link;
- public static function DBInsert($arg){
- $link = DB::DBlink();
- $res = mysqli_query($link, $arg) or die(mysqli_error($link));
- }
- public static function DBlink(){
- self::$host = "localhost";
- self::$user = "root";
- self::$password = "";
- self::$database = "cdlcrypto";
- self::$link = "";
- $link = mysqli_connect(self::$host, self::$user, self::$password, self::$database);
- if (isset($link) == 0) {
- echo "Unable to connect to MySQL." . PHP_EOL;
- echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
- exit;
- }
- return $link;
- }
- public static function SQLFETCH($sql)
- {
- $link = DB::DBlink();
- $res = mysqli_query($link, $sql) or die(mysqli_error($link));
- $result = [];
- if (isset($res)) {
- while ($item = $res->fetch_object()) {
- $result[] = $item;
- }
- return $result;
- } else {
- return "DB IS EMPTY";
- }
- }
- public function DBclearquery($sql)
- {
- $link = DB::DBlink();
- $res = mysqli_query($link, $sql) or die(mysqli_error($link));
- }
- }
- var_dump(DB::DBlink());
Add Comment
Please, Sign In to add comment