First commit.
This commit is contained in:
		
							
								
								
									
										19
									
								
								src/Libs/Database.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/Libs/Database.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,19 @@ | ||||
| <?php | ||||
| namespace Libs; | ||||
|  | ||||
| class Database { | ||||
|   static private $db; | ||||
|    | ||||
|   private function __construct() {} | ||||
|    | ||||
|   static public function getConnection() { | ||||
|     if (!isset(self::$db)) { | ||||
|       self::$db = new \mysqli(dbhost, dbuser, dbpass, dbname); | ||||
|       if (self::$db->connect_errno) { | ||||
|         exit('No se ha podido conectar a la base de datos.'); | ||||
|       } | ||||
|     } | ||||
|     return self::$db; | ||||
|   } | ||||
| } | ||||
| ?> | ||||
		Reference in New Issue
	
	Block a user