Revision a505dbd9
Added by Andreas Kohlbecker over 6 years ago
debug/db_debug.php.inc | ||
---|---|---|
1 |
<?php |
|
2 |
/** |
|
3 |
* Created by PhpStorm. |
|
4 |
* User: andreas |
|
5 |
* Date: 11.01.18 |
|
6 |
* Time: 12:39 |
|
7 |
* |
|
8 |
* Execute .e.g as |
|
9 |
* |
|
10 |
* php db_debug.php.inc sites/cyprus/settings.php |
|
11 |
* |
|
12 |
*/ |
|
13 |
|
|
14 |
$setting_file = $argv[1]; |
|
15 |
|
|
16 |
print ("Running db_debug.php with settings from " . $setting_file . "\n"); |
|
17 |
require($setting_file); |
|
18 |
print("db configuration:\n"); |
|
19 |
print_r($databases); |
|
20 |
print ("trying to connect to default db ...\n"); |
|
21 |
$db_test_settings = $databases["default"]["default"]; |
|
22 |
$mysqli = mysqli_connect($db_test_settings["host"], $db_test_settings["username"], $db_test_settings["password"], $db_test_settings["database"]); |
|
23 |
if ($mysqli->connect_errno) { |
|
24 |
echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error; |
|
25 |
} |
|
26 |
echo "Connection opened: " . $mysqli->host_info . "\n"; |
|
27 |
|
|
28 |
$res = $mysqli->query("SELECT * FROM " .$db_test_settings["prefix"]. "system"); |
|
29 |
|
|
30 |
echo "system table ...\n"; |
|
31 |
for ($row_no = $res->num_rows - 1; $row_no >= 0; $row_no--) { |
|
32 |
$res->data_seek($row_no); |
|
33 |
$row = $res->fetch_assoc(); |
|
34 |
echo " filename = " . $row['filename'] . "\n"; |
|
35 |
} |
|
36 |
|
|
37 |
|
Also available in: Unified diff
database debug script