-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbaza.class.php
53 lines (44 loc) · 1.27 KB
/
baza.class.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
43
44
45
46
47
48
49
50
51
52
53
<?php
class Baza{
const server="server";
const baza="db";
const korisnik="user";
const lozinka="pass";
function spojiBP(){
$mysqli=new mysqli(self::server, self::korisnik, self::lozinka , self::baza);
if($mysqli->connect_errno)
{
echo "Nuspjesno spajanje na bazu: {$mysqli->connect_errno}, {$mysqli->connect_error}";
}
//$mysqli->set_charset('utf8');
return $mysqli;
}
function prekidBP($veza){
$prekid=$veza->close();
return $prekid;
}
function selectUpiti($upit){
$veza=self::spojiBP();
$veza->query("SET NAMES 'utf8'");
$veza->query("SET CHARACTER_SET 'utf8'");
$rezultat=$veza->query($upit)or trigger_error("Greška kod upita: {$upit} - Greška: ".$veza->erorr.''.E_USER_ERORR);
if(!$rezultat){
$rezultat=null;
}
$veza->close();
return $rezultat;
}
function ostaliUpiti($upit){
$veza= self::spojiBP();
$veza->query("SET NAMES 'utf8'");
$veza->query("SET CHARACTER_SET 'utf8'");
if($rezultat=$veza->query($upit)){
$veza->close();
}
else{
echo "Pogreska: ".$veza->error;
}
return $rezultat;
}
}
?>