X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=inc%2Fdatabase.inc;h=12b87fa0b2630bd8fe8ed516cd74a9cf7e3cdafa;hb=e586807dafc64c3fe152ab518599e6cf3f0f84e1;hp=5d2e5454a4b400d12b2ca9dbdacd66dac14b8017;hpb=bc13d5d6e1834068f8b690c32bba114e352dacdd;p=mirrors%2FKyberia-bloodline.git diff --git a/inc/database.inc b/inc/database.inc old mode 100644 new mode 100755 index 5d2e545..12b87fa --- a/inc/database.inc +++ b/inc/database.inc @@ -1,37 +1,50 @@ connect("$this->Url","$this->User","$this->Password","$this->Database"); + +function CLASS_DATABASE ($database=DB_DATABASE,$user=DB_USER,$password=DB_PASS,$url=DB_HOST) { + $this->Database=$database; + $this->Password=$password; + $this->User=$user; + $this->Url=$url; + $this->connect($this->Url,$this->User,$this->Password,$this->Database); } function connect($url, $user, $password, $database, $halt_on_error = true) { + global $error; $this->_halt_on_error = $halt_on_error; if ($this->_linkId == false) { + $this->_linkId=mysql_connect($url, $user, $password); if ($this->_linkId == false) { - $this->exception("weej databazka to nerozdychava ;)"); + $error='chcipla databaza'; + $this->exception($error); return false; - die(); + //die(); } $this->_url=$url; $this->_user=$user; $this->_password=$password; + if ($this->_linkId == false || mysql_select_db($database, $this->_linkId) == false) { $this->exception("1Database failed."); return false; @@ -47,9 +60,17 @@ function closeMysql() { } function query($sql) { - global $user_id; - if ($user_id==220 && $_GET['debug']) echo $sql; - $this->_queryId = mysql_db_query($this->_database,$sql,$this->_linkId); + + + + $this->_queryId = mysql_query($sql,$this->_linkId); + + if ($_SESSION['user_id']==548) { + echo $sql; + global $timer_start; + echo "
".SubStr((Time()+SubStr(MicroTime(),0,8)-$timer_start),0,7); + } + if ($this->_queryId == false) { $this->exception("query failed ::$sql::"); } @@ -62,6 +83,17 @@ function executequery($sql) { return($this->query($sql)); } +function executetransaction($queries) { + $this->executequery("set autocommit=0"); + if (is_array($queries)) { + foreach ($queries as $query) { + $this->executequery($query); + } + } + $this->executequery("commit"); + $this->executequery("set autocommit=1"); +} + function executeupdate($sql) { return($this->update($sql)); }