<?php
class Db_layer {

public function query($str) {

switch(DB_TYPE) {
case "mysql":
$result=mysql_query($str, DB_HOST);
break;

case "sqlite":
$result=sqlite_query(DB_HOST, $str);
break;

default:
die("Neznamy typ databaze! (Unknown database type!)");
}

return $result;

}

public function fetch_array($str) {

switch(DB_TYPE) {
case "mysql":
return mysql_fetch_array($str);
break;

case "sqlite":
$result=sqlite_fetch_array($str);
break;

default:
die("Neznamy typ databaze! (Unknown database type!)");
}

return $result;

}

public function fetch_row($str) {

switch(DB_TYPE) {
case "mysql":
$result=mysql_fetch_row($str);
break;

case "sqlite":
$result=sqlite_fetch_array($str);
break;

default:
die("Neznamy typ databaze! (Unknown database type!)");
}

return $result;

}

public function num_rows($str) {

switch(DB_TYPE) {
case "mysql":
$result=mysql_num_rows($str);
break;

case "sqlite":
$result=sqlite_num_rows($str);
break;

default:
die("Neznamy typ databaze! (Unknown database type!)");
}

return $result;

}

public function escape($str) {

switch(DB_TYPE) {
case "mysql":
$result=mysql_real_escape_string($str);
break;

case "sqlite":
$result=sqlite_escape_string($str);
break;

default:
die("Neznamy typ databaze! (Unknown database type!)");
}

return $result;

}

function unescape($str) {

switch(DB_TYPE) {
case "mysql":
$result=stripslashes($str);
break;

case "sqlite":
$result=stripslashes($str);
break;

default:
die("Neznamy typ databaze! (Unknown database type!)");
}

return $result;

}

}
?>