source: includes/databaseconection.php@ 41

Last change on this file since 41 was 41, checked in by george, 16 years ago
  • Upraveno: Zjednodušení skriptu pro zobrazení bannerů a záznam odkazujících webu na bannery.
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1<?php
2
3class Database
4{
5 var $id_connection = 0;
6
7 function Database($address = 'localhost', $user = 'root', $pass = '')
8 {
9 $this->id_connection = mysql_connect($address, $user, $pass);
10 if(!$this->id_connection)
11 die('Spojení s MySQL databází se nezdařilo.');
12 }
13
14 function SelectDatabase($NameDatabase)
15 {
16 $return_selection = mysql_select_db($NameDatabase, $this->id_connection);
17 if(!$return_selection)
18 die('Databázi '.$NameDatabase.' se nám nepodařilo vybrat.');
19 }
20
21 function SQLCommand($Command)
22 {
23 $ReturnCommand = mysql_query($Command, $this->id_connection);
24 if(!$ReturnCommand)
25 {
26 die('Nepodařilo se aplikovat příkaz.');
27 } else
28 {
29 return $ReturnCommand;
30 }
31 }
32
33 function ReadFromDatabase($SQL)
34 {
35 $return_result = mysql_query($sql, $id_spojeni);
36 if (!$return_result)
37 {
38 die('Nepodařilo se nám načíst řádky z databáze.');
39 } else
40 {
41 return $return_result;
42 }
43 }
44
45 function Disconnect()
46 {
47 mysql_close($this->id_connection);
48 }
49}
50
51?>
Note: See TracBrowser for help on using the repository browser.