checking the engine can trigger a database init...

This commit is contained in:
Shish 2012-06-24 00:25:47 +01:00
parent 008cc4253b
commit bcfcca7cda

View file

@ -43,14 +43,14 @@ class User {
public static function by_session(/*string*/ $name, /*string*/ $session) {
global $config, $database;
if($database->engine->name === "mysql") {
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
}
else {
$query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess";
}
$row = $database->cache->get("user-session-$name-$session");
if(!$row) {
if($database->engine->name === "mysql") {
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
}
else {
$query = "SELECT * FROM users WHERE name = :name AND md5(pass || :ip) = :sess";
}
$row = $database->get_row($query, array("name"=>$name, "ip"=>get_session_ip($config), "sess"=>$session));
$database->cache->set("user-session-$name-$session", $row, 300);
}