-
Notifications
You must be signed in to change notification settings - Fork 0
/
conexion.php
40 lines (31 loc) · 829 Bytes
/
conexion.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* A class for handling connections to the database
*
* It calls mysqli_connect (if it hasn't been already called during the script execution)
* with configuration params.
*
*
*/
include('config/conf.php');
class Conexion{
static $conexion;
/**
* Creates a new mysqli object if not already created
*
* The object is created with configuration files parsed config directory
* with values concerning the database environment used.
*
*
* @return mysqli $conexion, an adapter object.
*/
public static function conectar() {
if(!isset(self::$conexion)) {
self::$conexion = mysqli_connect(HOST,USER,PASS,DB);
}
if(self::$conexion === false) {
return mysqli_connect_error();
}
return self::$conexion;
}
}