68 lines
No EOL
1.7 KiB
PHP
68 lines
No EOL
1.7 KiB
PHP
<?php
|
|
$db_host = "koc.se";
|
|
$db_database = "";
|
|
$db_user = "";
|
|
$db_password = "";
|
|
|
|
|
|
function dbconnect(){
|
|
@mysql_pconnect($GLOBALS['db_host'],$GLOBALS['db_user'],$GLOBALS['db_password'])
|
|
or die("ERROR CONNECTING TO DATABASE ".$GLOBALS['db_host']."!!!");
|
|
@mysql_select_db($GLOBALS['db_database'])
|
|
or die("THE DATABASE <b>".$GLOBALS['db_database']."</b> DO NOT EXIST!!!");
|
|
}
|
|
|
|
function dbdisconnect(){
|
|
@mysql_close();
|
|
}
|
|
|
|
function getTableRow($table, $id){
|
|
$sqlSats = "SELECT * FROM ".$table." WHERE id=".$id;
|
|
return runSimpleQuery($sqlSats);
|
|
}
|
|
|
|
function getTableCount($table){
|
|
$sqlSats = "SELECT * FROM ".$table;
|
|
return runSimpleQuery($sqlSats);
|
|
}
|
|
|
|
function getDBLastUpdateTime(){
|
|
$query = runQueryArray("SHOW TABLE STATUS");
|
|
foreach($query as $row){
|
|
if(empty($ret) || $row["Update_time"] > $ret){
|
|
$ret = $row["Update_time"];
|
|
}
|
|
}
|
|
return date("D F o H:i",strtotime($ret));
|
|
}
|
|
|
|
function dbSaveLog($url,$message,$date){
|
|
runSimpleQuery("INSERT INTO log VALUES (null,'$url','$message','$date')");
|
|
}
|
|
|
|
function runQueryArray($sqlSats){
|
|
$resultat = array();
|
|
$sql = @mysql_query($sqlSats);
|
|
if($sql == false){
|
|
trigger_error("ARRAY QUERY FAILD: \"".$sqlSats."\"", E_USER_ERROR);
|
|
die();
|
|
}
|
|
while ($row = mysql_fetch_array($sql,MYSQL_ASSOC)){
|
|
array_push($resultat, $row);
|
|
}
|
|
return $resultat;
|
|
}
|
|
|
|
function runSimpleQuery($sqlSats){
|
|
$resultat = @mysql_query($sqlSats);
|
|
if($resultat == false){
|
|
trigger_error("QUERY FAILD: \"".$sqlSats."\"", E_USER_ERROR);
|
|
die();
|
|
}
|
|
if(is_bool($resultat) || is_int($resultat))
|
|
return $resultat;
|
|
else
|
|
return @mysql_fetch_assoc($resultat);
|
|
}
|
|
|
|
?>
|