X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=inc%2Fdatabase.inc;fp=inc%2Fdatabase.inc;h=0000000000000000000000000000000000000000;hb=f9b322cc7cb38f9d23168c291ebc3e49040a4999;hp=53f698d5588c649bc8a6b65644ba3ec369cff10d;hpb=673e23209e2e3b9782c037e70156a1a20154a5b9;p=mirrors%2FKyberia-bloodline.git diff --git a/inc/database.inc b/inc/database.inc deleted file mode 100644 index 53f698d..0000000 --- a/inc/database.inc +++ /dev/null @@ -1,151 +0,0 @@ -Database=$database; - $this->Password=$password; - $this->User=$user; - $this->Url=$url; -*/ - -function CLASS_DATABASE() { - $this->connect(DB_HOST,DB_USER,DB_PASS,DB_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) { - $error='chcipla databaza'; - $this->exception($error); - return false; - //die(); - }// else { - // mysql_query('set character set utf8'); - //} - $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; - die(); - } - $this->_database=$database; - } - return true; -} - -function closeMysql() { - mysql_close($this->_linkId); -} - -function query($sql) { - -// if (preg_match("/^select/i",$sql) && (rand(0,1000)>MASTER2SLAVE) && $this->Master) { -// every select query goes to onyx + opraveny regexp, aby matchoval vnorene selecty (br) - if (preg_match('/^\(?select/i',$sql) && $this->Master) { - $this->_linkId = false; - $this->connect(SLAVE_HOST,SLAVE_USER,SLAVE_PASS,SLAVE_DATABASE); - $this->Master = false; - - } - - elseif (!preg_match("/^select/i",$sql) && !$this->Master) { - $this->_linkId = false; - $this->connect(DB_HOST,DB_USER,DB_PASS,DB_DATABASE); - $this->Master = true; - } - - $this->_queryId = mysql_query($sql,$this->_linkId); - - if ($_SESSION['debugging']) { - if ($this->Master) echo "Master::"; - else echo "Slave::"; - 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::"); - } - - return new result($this->_queryId, $sql); - } - - -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)); -} - -function update($sql) { - if (!$this->Master) { - $this->_linkId = false; - $this->connect(DB_HOST,DB_USER,DB_PASS,DB_DATABASE); - $this->Master = true; - } - - $this->_queryId = @mysql_db_query($this->_database,$sql,$this->_linkId); - if ($this->_queryId == false) { - $this->exception("update failed."); - } - $rows=@mysql_affected_rows($this->_linkId); - return($rows); -} - -function getLastInsertId() { - return(@mysql_insert_id($this->_linkId)); -} - -function exception($errorMessage) { - - echo ""; - - if ($this->_halt_on_error) { - die("
".$errorMessage."
"); - } else { - echo $errorMessage."
"; - return false; - } - } -} -?>