-
Notifications
You must be signed in to change notification settings - Fork 0
/
Connexio.php
42 lines (36 loc) · 992 Bytes
/
Connexio.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
41
42
<?php
class Connexio {
private $usr;
private $pwd;
private $ip;
public function __construct($usr='pau',$pwd='pau',$ip='localhost')
{
$this->ip = $ip;
$this->usr = $usr;
$this->pwd = $pwd;
$this->connectar();
$this->selectdb("socialtravel");
}
// Realitzem la connexio a la base de dades
function connectar(){
if( mysql_set_charset('utf8', mysql_connect($this->ip,$this->usr,$this->pwd)) ) return true;
return false;
}
// Seleccionem la Base de dades
function selectdb($bd)
{
if( mysql_select_db($bd) ) return true;
return false;
}
// Consulta SQL
function query($query)
{
$result = mysql_query($query);
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
return $result;
}
}
?>