mirror of
https://github.com/kvazar-network/webapp.git
synced 2025-01-09 06:38:02 +00:00
init sqlite edition
This commit is contained in:
parent
d22bc1a539
commit
808b11fb7d
@ -6,13 +6,11 @@ ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Application
|
||||
define('BASE_URL', 'https://kvazar.ml');
|
||||
define('BASE_URL', '/');
|
||||
define('PAGE_LIMIT', 10);
|
||||
define('SEF_MODE', true);
|
||||
define('SEF_MODE', false);
|
||||
|
||||
// Database
|
||||
define('DB_HOST', 'localhost');
|
||||
define('DB_PORT', '3306');
|
||||
define('DB_NAME', '');
|
||||
define('DB_NAME', 'kvazar.dat');
|
||||
define('DB_USERNAME', '');
|
||||
define('DB_PASSWORD', '');
|
||||
|
6
library/mysql.php → library/sqlite.php
Executable file → Normal file
6
library/mysql.php → library/sqlite.php
Executable file → Normal file
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
class MySQL {
|
||||
class SQLite {
|
||||
|
||||
public function __construct() {
|
||||
public function __construct($database, $username, $password) {
|
||||
|
||||
try {
|
||||
|
||||
$this->_db = new PDO('mysql:dbname=' . DB_NAME . ';host=' . DB_HOST . ';port=' . DB_PORT . ';charset=utf8', DB_USERNAME, DB_PASSWORD, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
|
||||
$this->_db = new PDO('sqlite:' . $database, $username, $password, [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
|
||||
$this->_db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$this->_db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||
$this->_db->setAttribute(PDO::ATTR_TIMEOUT, 600);
|
@ -2,7 +2,7 @@
|
||||
|
||||
require_once('../config.php');
|
||||
require_once('../library/icon.php');
|
||||
require_once('../library/mysql.php');
|
||||
require_once('../library/sqlite.php');
|
||||
|
||||
$query = isset($_GET['q']) ? $_GET['q'] : false;
|
||||
$ns = isset($_GET['ns']) ? preg_replace('/[^a-zA-Z0-9]+/', '', $_GET['ns']) : false;
|
||||
@ -38,7 +38,7 @@ if ($page > 0) {
|
||||
$limit = PAGE_LIMIT * $page;
|
||||
}
|
||||
|
||||
$db = new MySQL();
|
||||
$db = new SQLite(DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
|
||||
if ($ns) {
|
||||
$namespaceValue = $db->getNamespaceName($ns);
|
||||
|
Loading…
Reference in New Issue
Block a user