function sql_connect($server, $username, $password, $database = "") { if (SETUP_DB_TYPE == "mysqli") { if (!($link = mysqli_connect($server, $username, $password, $database))) { return false; } sys::$db = $link; if (!sql_query("set names 'utf8', sql_mode = ''")) { return false; } } else { if (SETUP_DB_TYPE == "pgsql") { $conn = "host='" . addslashes($server) . "' user='******' password='******'"; if ($database != "") { $conn .= " dbname='" . addslashes($database) . "'"; } if (!($link = pg_pconnect($conn))) { return false; } sys::$db = $link; } else { if (SETUP_DB_TYPE == "sqlite") { try { $link = new PDO("sqlite:" . SIMPLE_STORE . "/sqlite3_" . urlencode($database) . ".db", "", "", array(PDO::ATTR_PERSISTENT => false)); $link->sqliteCreateFunction("REGEXP_LIKE", "_sql_sqlite_match", 2); sys::$db = $link; } catch (Exception $e) { sys::$db_error = $e->getMessage(); return false; } } } } return true; }