-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdb.php
65 lines (59 loc) · 2.02 KB
/
db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Main integration file.
*
* @package wp-sqlite-integration
* @since 1.0.0
*/
// Require the constants file.
require_once dirname( __DIR__, 2 ) . '/constants.php';
// Bail early if DB_ENGINE is not defined as sqlite.
if ( ! defined( 'DB_ENGINE' ) || 'sqlite' !== DB_ENGINE ) {
return;
}
if ( ! extension_loaded( 'pdo' ) ) {
wp_die(
new WP_Error(
'pdo_not_loaded',
sprintf(
'<h1>%1$s</h1><p>%2$s</p>',
'PHP PDO Extension is not loaded',
'Your PHP installation appears to be missing the PDO extension which is required for this version of WordPress and the type of database you have specified.'
)
),
'PHP PDO Extension is not loaded.'
);
}
if ( ! extension_loaded( 'pdo_sqlite' ) ) {
wp_die(
new WP_Error(
'pdo_driver_not_loaded',
sprintf(
'<h1>%1$s</h1><p>%2$s</p>',
'PDO Driver for SQLite is missing',
'Your PHP installation appears not to have the right PDO drivers loaded. These are required for this version of WordPress and the type of database you have specified.'
)
),
'PDO Driver for SQLite is missing.'
);
}
require_once __DIR__ . '/class-wp-sqlite-lexer.php';
require_once __DIR__ . '/class-wp-sqlite-query-rewriter.php';
require_once __DIR__ . '/class-wp-sqlite-translator.php';
require_once __DIR__ . '/class-wp-sqlite-token.php';
require_once __DIR__ . '/class-wp-sqlite-pdo-user-defined-functions.php';
require_once __DIR__ . '/class-wp-sqlite-db.php';
require_once __DIR__ . '/install-functions.php';
/*
* Debug: Cross-check with MySQL.
* This is for debugging purpose only and requires files
* that are present in the GitHub repository
* but not the plugin published on WordPress.org.
*/
$crosscheck_tests_file_path = dirname( __DIR__, 2 ) . '/tests/class-wp-sqlite-crosscheck-db.php';
if ( defined( 'SQLITE_DEBUG_CROSSCHECK' ) && SQLITE_DEBUG_CROSSCHECK && file_exists( $crosscheck_tests_file_path ) ) {
require_once $crosscheck_tests_file_path;
$GLOBALS['wpdb'] = new WP_SQLite_Crosscheck_DB( DB_NAME );
} else {
$GLOBALS['wpdb'] = new WP_SQLite_DB( DB_NAME );
}