3 include_once ("result.inc");
4 include_once ("configdb.inc");
8 var $Database=DB_DATABASE;
10 var $Password=DB_PASS;
17 var $_database = "kyberia";
18 var $_halt_on_error = true;
19 function CLASS_DATABASE () {
20 $this->connect("$this->Url","$this->User","$this->Password","$this->Database");
23 function connect($url, $user, $password, $database, $halt_on_error = true) {
24 $this->_halt_on_error = $halt_on_error;
25 if ($this->_linkId == false) {
26 $this->_linkId=mysql_connect($url, $user, $password);
27 if ($this->_linkId == false) {
28 $this->exception("weej databazka to nerozdychava ;)");
34 $this->_password=$password;
35 if ($this->_linkId == false || mysql_select_db($database, $this->_linkId) == false) {
36 $this->exception("1Database failed.");
40 $this->_database=$database;
45 function closeMysql() {
46 mysql_close($this->_linkId);
49 function query($sql) {
51 if ($user_id==220 && $_GET['debug']) echo $sql;
52 $this->_queryId = mysql_db_query($this->_database,$sql,$this->_linkId);
53 if ($this->_queryId == false) {
54 $this->exception("query failed ::$sql::");
57 return new result($this->_queryId, $sql);
61 function executequery($sql) {
62 return($this->query($sql));
65 function executeupdate($sql) {
66 return($this->update($sql));
69 function update($sql) {
71 $this->_queryId = @mysql_db_query($this->_database,$sql,$this->_linkId);
72 if ($this->_queryId == false) {
73 $this->exception("update failed.");
75 $rows=@mysql_affected_rows($this->_linkId);
79 function getLastInsertId() {
80 return(@mysql_insert_id($this->_linkId));
83 function exception($errorMessage) {
85 echo @mysql_error($this->_linkId)," (",@mysql_errno($this->_linkId),")";
87 if ($this->_halt_on_error) {
88 die("<pre>".$errorMessage."</pre>");
90 echo $errorMessage."<br>";