https://www.adminer.org/en/drivers/
を参考に
php compile.php $driver
エラーメッセージからmongodbに関与する部分
Missing function set_charset in /root/adminer/adminer/drivers/mongo.inc.php Missing function result in /root/adminer/adminer/drivers/mongo.inc.php Missing function multi_query in /root/adminer/adminer/drivers/mongo.inc.php Missing function store_result in /root/adminer/adminer/drivers/mongo.inc.php Missing function next_result in /root/adminer/adminer/drivers/mongo.inc.php Missing function insertUpdate in /root/adminer/adminer/drivers/mongo.inc.php Missing function limit in /root/adminer/adminer/drivers/mongo.inc.php Missing function limit1 in /root/adminer/adminer/drivers/mongo.inc.php Missing function view in /root/adminer/adminer/drivers/mongo.inc.php Missing function create_database in /root/adminer/adminer/drivers/mongo.inc.php Missing function rename_database in /root/adminer/adminer/drivers/mongo.inc.php Missing function auto_increment in /root/adminer/adminer/drivers/mongo.inc.php Missing function drop_views in /root/adminer/adminer/drivers/mongo.inc.php Missing function move_tables in /root/adminer/adminer/drivers/mongo.inc.php Missing function copy_tables in /root/adminer/adminer/drivers/mongo.inc.php Missing function trigger in /root/adminer/adminer/drivers/mongo.inc.php Missing function triggers in /root/adminer/adminer/drivers/mongo.inc.php Missing function trigger_options in /root/adminer/adminer/drivers/mongo.inc.php Missing function routine in /root/adminer/adminer/drivers/mongo.inc.php Missing function routines in /root/adminer/adminer/drivers/mongo.inc.php Missing function routine_languages in /root/adminer/adminer/drivers/mongo.inc.ph p Missing function explain in /root/adminer/adminer/drivers/mongo.inc.php Missing function types in /root/adminer/adminer/drivers/mongo.inc.php Missing function schemas in /root/adminer/adminer/drivers/mongo.inc.php Missing function get_schema in /root/adminer/adminer/drivers/mongo.inc.php Missing function set_schema in /root/adminer/adminer/drivers/mongo.inc.php Missing function create_sql in /root/adminer/adminer/drivers/mongo.inc.php Missing function truncate_sql in /root/adminer/adminer/drivers/mongo.inc.php Missing function use_sql in /root/adminer/adminer/drivers/mongo.inc.php Missing function trigger_sql in /root/adminer/adminer/drivers/mongo.inc.php Missing function show_variables in /root/adminer/adminer/drivers/mongo.inc.php Missing function process_list in /root/adminer/adminer/drivers/mongo.inc.php Missing function show_status in /root/adminer/adminer/drivers/mongo.inc.php Missing function kill_process in /root/adminer/adminer/drivers/mongo.inc.php Missing function max_connections in /root/adminer/adminer/drivers/mongo.inc.php
を読み取る。
adminer/drivers/mysql.inc.phpから対応する関数を読み取る。今回は
function set_charset($charset) { if (parent::set_charset($charset)) { return true; } // the client library may not support utf8mb4 parent::set_charset('utf8'); return $this->query("SET NAMES $charset"); } function result($query, $field = 0) { $result = $this->query($query); if (!$result) { return false; } $row = $result->fetch_array(); return $row[$field]; } function multi_query($query) { return $this->_result = $this->query($query); } function store_result() { return $this->_result; } function next_result() { // MySQL extension doesn't support multiple results return false; } function insertUpdate($table, $rows, $primary) { $columns = array_keys(reset($rows)); $prefix = "INSERT INTO " . table($table) . " (" . implode(", ", $columns) . ") VALUES\n"; $values = array(); foreach ($columns as $key) { $values[$key] = "$key = VALUES($key)"; } $suffix = "\nON DUPLICATE KEY UPDATE " . implode(", ", $values); $values = array(); $length = 0; foreach ($rows as $set) { $value = "(" . implode(", ", $set) . ")"; if ($values && (strlen($prefix) + $length + strlen($value) + strlen($suffix) > 1e6)) { // 1e6 - default max_allowed_packet if (!queries($prefix . implode(",\n", $values) . $suffix)) { return false; } $values = array(); $length = 0; } $values[] = $value; $length += strlen($value) + 2; // 2 - strlen(",\n") } return queries($prefix . implode(",\n", $values) . $suffix); } function limit($query, $where, $limit, $offset = 0, $separator = " ") { return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : ""); } function limit1($query, $where) { return limit($query, $where, 1); } function view($name) { global $connection; return array("select" => preg_replace('~^(?:[^`]|`[^`]*`)*\\s+AS\\s+~isU', '', $connection->result("SHOW CREATE VIEW " . table($name), 1))); } function create_database($db, $collation) { return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " COLLATE " . q($collation) : "")); } function rename_database($name, $collation) { $return = false; if (create_database($name, $collation)) { //! move triggers $rename = array(); foreach (tables_list() as $table => $type) { $rename[] = table($table) . " TO " . idf_escape($name) . "." . table($table); } $return = (!$rename || queries("RENAME TABLE " . implode(", ", $rename))); if ($return) { queries("DROP DATABASE " . idf_escape(DB)); } restart_session(); set_session("dbs", null); } return $return; } function auto_increment() { $auto_increment_index = " PRIMARY KEY"; // don't overwrite primary key by auto_increment if ($_GET["create"] != "" && $_POST["auto_increment_col"]) { foreach (indexes($_GET["create"]) as $index) { if (in_array($_POST["fields"][$_POST["auto_increment_col"]]["orig"], $index["columns"], true)) { $auto_increment_index = ""; break; } if ($index["type"] == "PRIMARY") { $auto_increment_index = " UNIQUE"; } } } return " AUTO_INCREMENT$auto_increment_index"; } function drop_views($views) { return queries("DROP VIEW " . implode(", ", array_map('table', $views))); } function move_tables($tables, $views, $target) { $rename = array(); foreach (array_merge($tables, $views) as $table) { // views will report SQL error $rename[] = table($table) . " TO " . idf_escape($target) . "." . table($table); } return queries("RENAME TABLE " . implode(", ", $rename)); //! move triggers } function copy_tables($tables, $views, $target) { queries("SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'"); foreach ($tables as $table) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); if (!queries("\nDROP TABLE IF EXISTS $name") || !queries("CREATE TABLE $name LIKE " . table($table)) || !queries("INSERT INTO $name SELECT * FROM " . table($table)) ) { return false; } } foreach ($views as $table) { $name = ($target == DB ? table("copy_$table") : idf_escape($target) . "." . table($table)); $view = view($table); if (!queries("DROP VIEW IF EXISTS $name") || !queries("CREATE VIEW $name AS $view[select]") //! USE to avoid db.table ) { return false; } } return true; } function trigger($name) { if ($name == "") { return array(); } $rows = get_rows("SHOW TRIGGERS WHERE `Trigger` = " . q($name)); return reset($rows); } /** Get defined triggers * @param string * @return array array($name => array($timing, $event)) */ function triggers($table) { $return = array(); foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_\\"))) as $row) { $return[$row["Trigger"]] = array($row["Timing"], $row["Event"]); } return $return; } /** Get trigger options * @return array ("Timing" => array(), "Event" => array(), "Type" => array()) */ function trigger_options() { return array( "Timing" => array("BEFORE", "AFTER"), "Event" => array("INSERT", "UPDATE", "DELETE"), "Type" => array("FOR EACH ROW"), ); } function routine($name, $type) { global $connection, $enum_length, $inout, $types; $aliases = array("bool", "boolean", "integer", "double precision", "real", "dec", "numeric", "fixed", "national char", "national varchar"); $type_pattern = "((" . implode("|", array_merge(array_keys($types), $aliases)) . ")\\b(?:\\s*\\(((?:[^'\")]|$enum_length)++)\\))?\\s*(zerofill\\s*)?(unsigned(?:\\s+zerofill)?)?)(?:\\s*(?:CHARSET|CHARACTER\\s+SET)\\s*['\"]?([^'\"\\s,]+)['\"]?)?"; $pattern = "\\s*(" . ($type == "FUNCTION" ? "" : $inout) . ")?\\s*(?:`((?:[^`]|``)*)`\\s*|\\b(\\S+)\\s+)$type_pattern"; $create = $connection->result("SHOW CREATE $type " . idf_escape($name), 2); preg_match("~\\(((?:$pattern\\s*,?)*)\\)\\s*" . ($type == "FUNCTION" ? "RETURNS\\s+$type_pattern\\s+" : "") . "(.*)~is", $create, $match); $fields = array(); preg_match_all("~$pattern\\s*,?~is", $match[1], $matches, PREG_SET_ORDER); foreach ($matches as $param) { $name = str_replace("``", "`", $param[2]) . $param[3]; $fields[] = array( "field" => $name, "type" => strtolower($param[5]), "length" => preg_replace_callback("~$enum_length~s", 'normalize_enum', $param[6]), "unsigned" => strtolower(preg_replace('~\\s+~', ' ', trim("$param[8] $param[7]"))), "null" => 1, "full_type" => $param[4], "inout" => strtoupper($param[1]), "collation" => strtolower($param[9]), ); } if ($type != "FUNCTION") { return array("fields" => $fields, "definition" => $match[11]); } return array( "fields" => $fields, "returns" => array("type" => $match[12], "length" => $match[13], "unsigned" => $match[15], "collation" => $match[16]), "definition" => $match[17], "language" => "SQL", // available in information_schema.ROUTINES.PARAMETER_STYLE ); } /** Get list of routines * @return array ("ROUTINE_TYPE" => , "ROUTINE_NAME" => , "DTD_IDENTIFIER" => ) */ function routines() { return get_rows("SELECT ROUTINE_NAME, ROUTINE_TYPE, DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . q(DB)); } /** Get list of available routine languages * @return array */ function routine_languages() { return array(); // "SQL" not required } function explain($connection, $query) { return $connection->query("EXPLAIN " . ($connection->server_info >= 5.1 ? "PARTITIONS " : "") . $query); } function types() { return array(); } /** Get existing schemas * @return array */ function schemas() { return array(); } /** Get current schema * @return string */ function get_schema() { return ""; } /** Set current schema * @param string * @return bool */ function set_schema($schema) { return true; } /** Get SQL command to create table * @param string * @param bool * @return string */ function create_sql($table, $auto_increment) { global $connection; $return = $connection->result("SHOW CREATE TABLE " . table($table), 1); if (!$auto_increment) { $return = preg_replace('~ AUTO_INCREMENT=\\d+~', '', $return); //! skip comments } return $return; } /** Get SQL command to truncate table * @param string * @return string */ function truncate_sql($table) { return "TRUNCATE " . table($table); } function use_sql($database) { return "USE " . idf_escape($database); } /** Get SQL commands to create triggers * @param string * @param string * @return string */ function trigger_sql($table, $style) { $return = ""; foreach (get_rows("SHOW TRIGGERS LIKE " . q(addcslashes($table, "%_\\")), null, "-- ") as $row) { $return .= "\n" . ($style == 'CREATE+ALTER' ? "DROP TRIGGER IF EXISTS " . idf_escape($row["Trigger"]) . ";;\n" : "") . "CREATE TRIGGER " . idf_escape($row["Trigger"]) . " $row[Timing] $row[Event] ON " . table($row["Table"]) . " FOR EACH ROW\n$row[Statement];;\n"; } return $return; } /** Get server variables * @return array ($name => $value) */ function show_variables() { return get_key_vals("SHOW VARIABLES"); } /** Get process list * @return array ($row) */ function process_list() { return get_rows("SHOW FULL PROCESSLIST"); } /** Get status variables * @return array ($name => $value) */ function show_status() { return get_key_vals("SHOW STATUS"); } function kill_process($val) { return queries("KILL " . number($val)); } function max_connections() { global $connection; return $connection->result("SELECT @@max_connections"); }
だったので、mongo.inc.phpの末尾に追加、再度コンパイル
php compile.php mongo
新しいadminer-mongo.phpが生成したが、うまく動作せず。時間があればエラー確認。