Adminer - dostosowanie
Adminer tak samo jak i Editor zapewniają wsparcie dla rozszerzeń. Część domyślnej funkcjonalnośi Adminera może być przepisana własnym kodem. Wszystko, co musisz zrobić, to definiować funkcję adminer_object, która wraca obiekt rozszerzający podstawową klase Adminer. Następnie wystarczy włożyć oryginalny adminer.php lub editor.php:
<?php
function adminer_object() {
class AdminerSoftware extends Adminer {
function name() {
// custom name in title and heading
return 'Software';
}
function permanentLogin() {
// key used for permanent login
return "8407170da45477e915061ebf767482b1";
}
function credentials() {
// server, username and password for connecting to database
return array('localhost', 'ODBC', '');
}
function database() {
// database name, will be escaped by Adminer
return 'software';
}
function login($login, $password) {
// validate user submitted credentials
return ($login == 'admin' && $password == '');
}
function tableName($tableStatus) {
// tables without comments would return empty string and will be ignored by Adminer
return h($tableStatus["Comment"]);
}
function fieldName($field, $order = 0) {
// only columns with comments will be displayed and only the first five in select
return ($order <= 5 && !ereg('_(md5|sha1)$', $field["field"]) ? h($field["comment"]) : "");
}
}
return new AdminerSoftware;
}
include "./editor.php";
To create an Adminer Editor customization for other drivers than MySQL, you have to define own loginForm method and fill the auth[driver] field value by your driver (pgsql, sqlite, ...).
API referencja

Obiekt może przepisać następne metody:
- string name() - Name in title and navigation
- array credentials() - Connection parameters
- string permanentLogin() - Get key used for permanent login
- string database() - Identifier of selected database
- array databases(bool $flush) - Get cached list of databases
- float queryTimeout() - Specify limit for waiting on some slow queries like DB list
- bool headers() - Headers to send before HTML output
- bool head() - Print HTML code inside <head>
- null loginForm() - Print login form
- bool login(string $login, string $password) - Authorize the user
- string tableName(array $tableStatus) - Table caption used in navigation and headings
- string fieldName(array $field, int $order) - Field caption used in select and edit
- null selectLinks(array $tableStatus, string $set) - Print links after select heading
- array foreignKeys(string $table) - Get foreign keys for table
- array backwardKeys(string $table, string $tableName) - Find backward keys for table
- null backwardKeysPrint(array $backwardKeys, array $row) - Print backward keys for row
- string selectQuery(string $query) - Query printed in select before execution
- string rowDescription(string $table) - Description of a row in a table
- array rowDescriptions(array $rows, array $foreignKeys) - Get descriptions of selected data
- string selectLink(string $val, array $field) - Get a link to use in select table
- string selectVal(string $val, string $link, array $field) - Value printed in select table
- string editVal(string $val, array $field) - Value conversion used in select and edit
- null selectColumnsPrint(array $select, array $columns) - Print columns box in select
- null selectSearchPrint(array $where, array $columns, array $indexes) - Print search box in select
- null selectOrderPrint(array $order, array $columns, array $indexes) - Print order box in select
- null selectLimitPrint(string $limit) - Print limit box in select
- null selectLengthPrint(string $text_length) - Print text length box in select
- null selectActionPrint(array $indexes) - Print action box in select
- bool selectCommandPrint() - Print command box in select
- bool selectImportPrint() - Print import box in select
- null selectEmailPrint(array $emailFields, array $columns) - Print extra text in the end of a select form
- array selectColumnsProcess(array $columns, array $indexes) - Process columns box in select
- array selectSearchProcess(array $fields, array $indexes) - Process search box in select
- array selectOrderProcess(array $fields, array $indexes) - Process order box in select
- string selectLimitProcess() - Process limit box in select
- string selectLengthProcess() - Process length box in select
- bool selectEmailProcess(array $where, array $foreignKeys) - Process extras in select form
- string selectQueryBuild(array $select, array $where, array $group, array $order, int $limit, int $page) - Build SQL query used in select
- string messageQuery(string $query) - Query printed after execution in the message
- array editFunctions(array $field) - Functions displayed in edit form
- string editInput(string $table, array $field, string $attrs, string $value) - Get options to display edit field
- string processInput(array $field, string $value, string $function) - Process sent input
- array dumpOutput() - Returns export output options
- array dumpFormat() - Returns export format options
- null dumpDatabase(string $db) - Export database structure
- null dumpTable(string $table, string $style, bool $is_view) - Export table structure
- null dumpData(string $table, string $style, string $query) - Export table data
- string dumpFilename(string $identifier) - Set export filename
- string dumpHeaders(string $identifier, bool $multi_table) - Send headers for export
- bool homepage() - Print homepage
- null navigation(string $missing) - Prints navigation after Adminer title
- null databasesPrint(string $missing) - Prints databases list in menu
- null tablesPrint(array $tables) - Prints table list in menu
Można korzystać z następujących funkcji globalnych.
- Min_DB connection() - Get database connection
- Adminer adminer() - Get Adminer object
- string idf_unescape(string $idf) - Unescape database identifier
- string escape_string(string $val) - Escape string to use inside ''
- null remove_slashes(array $process, bool $filter) - Disable magic_quotes_gpc
- string bracket_escape(string $idf, bool $back) - Escape or unescape string to use inside form []
- string h(string $string) - Escape for HTML
- string nbsp(string $string) - Escape for TD
- string nl_br(string $string) - Convert \n to <br>
- string checkbox(string $name, string $value, bool $checked, string $label, string $onclick, bool $jsonly) - Generate HTML checkbox
- string optionlist(array $options, mixed $selected, bool $use_keys) - Generate list of HTML options
- string html_select(string $name, array $options, string $value, string $onchange) - Generate HTML radio list
- string confirm(string $count) - Get onclick confirmation
- null print_fieldset(string $id, string $legend, bool $visible, string $onclick) - Print header for hidden fieldset (close by </div></fieldset>)
- string bold(bool $bold) - Return class='active' if $bold is true
- string odd(string $return) - Generate class for odd rows
- string js_escape(string $string) - Escape string for JavaScript apostrophes
- null json_row(string $key, string $val) - Print one row in JSON object
- bool ini_bool(string $ini) - Get INI boolean value
- bool sid() - Check if SID is neccessary
- string q(string $string) - Shortcut for $connection->quote($string)
- array get_vals(string $query, mixed $column) - Get list of values from database
- array get_key_vals(string $query, Min_DB $connection2) - Get keys from first column and values from second
- array get_rows(string $query, Min_DB $connection2, string $error) - Get all rows of result
- array unique_array(array $row, array $indexes) - Find unique identifier of a row
- string where(array $where, array $fields) - Create SQL condition from parsed query string
- string where_check(string $val, array $fields) - Create SQL condition from query string
- string where_link(int $i, string $column, string $value, string $operator) - Create query string where condition from value
- bool cookie(string $name, string $value) - Set cookie valid for 1 month
- null restart_session() - Restart stopped session
- null stop_session() - Stop session if it would be possible to restart it later
- mixed get_session(string $key) - Get session variable for current server
- mixed set_session(string $key, mixed $val) - Set session variable for current server
- string auth_url(string $driver, string $server, string $username, string $db) - Get authenticated URL
- bool is_ajax() - Find whether it is an AJAX request
- null redirect(string $location, string $message) - Send Location header and exit
- bool query_redirect(string $query, string $location, string $message, bool $redirect, bool $execute, bool $failed) - Execute query and redirect if successful
- Min_Result queries(string $query) - Execute and remember query
- bool apply_queries(string $query, array $tables, callback $escape) - Apply command to all array items
- bool queries_redirect(string $location, string $message, bool $redirect) - Redirect by remembered queries
- string remove_from_uri(string $param) - Remove parameter from query string
- string pagination(int $page, int $current) - Generate page number for pagination
- mixed get_file(string $key, bool $decompress) - Get file contents from $_FILES
- string upload_error(int $error) - Determine upload error
- string repeat_pattern(string $pattern, int $length) - Create repeat pattern for preg
- bool is_utf8(string $val) - Check whether the string is in UTF-8
- string shorten_utf8(string $string, int $length, string $suffix) - Shorten UTF-8 string
- string friendly_url(string $val) - Generate friendly URL
- null hidden_fields(array $process, array $ignore) - Print hidden fields
- null hidden_fields_get() - Print hidden fields for GET forms
- array column_foreign_keys(string $table) - Find out foreign keys for each column
- null enum_input(string $type, string $attrs, array $field, mixed $value, string $empty) - Print enum input field
- null input(array $field, mixed $value, string $function) - Print edit input field
- string process_input(one $field) - Process edit input field
- null search_tables() - Print results of search in all tables
- string dump_headers(string $identifier, bool $multi_table) - Send headers for export
- null dump_csv(array $row) - Print CSV row
- string apply_sql_function(string $function, string $column) - Apply SQL function
- string password_file() - Read password from file adminer.key in temporary directory or create one
- bool is_mail(string $email) - Check whether the string is e-mail address
- string is_url(string $string) - Check whether the string is URL address
- bool is_shortable(array $field) - Check if field should be shortened
- Min_Result slow_query(string $query) - Run query which can be killed by AJAX call after timing out
Min_DB:
- bool connect(string $server, string $username, string $password) - Connect to server
- string quote(string $string) - Quote string to use in SQL
- bool select_db(string $database) - Select database
- mixed query(string $query, bool $unbuffered) - Send query
- bool multi_query(string $query) - Send query with more resultsets
- Min_Result store_result() - Get current resultset
- bool next_result() - Fetch next resultset
- string result(string $query, int $field) - Get single field from result
Min_Result:
Funkcje charakterystyczne dla kierownika:
- string idf_escape(string $idf) - Escape database identifier
- string table(string $idf) - Get escaped table name
- mixed connect() - Connect to the database
- array get_databases(bool $flush) - Get cached list of databases
- string limit(string $query, string $where, int $limit, int $offset, string $separator) - Formulate SQL query with limit
- string limit1(string $query, string $where) - Formulate SQL modification query with limit 1
- string db_collation(string $db, array $collations) - Get database collation
- array engines() - Get supported engines
- string logged_user() - Get logged user
- array tables_list() - Get tables list
- array count_tables(array $databases) - Count tables in all databases
- array table_status(string $name) - Get table status
- bool is_view(array $table_status) - Find out whether the identifier is view
- bool fk_support(array $table_status) - Check if table supports foreign keys
- array fields(string $table) - Get information about fields
- array indexes(string $table, string $connection2) - Get table indexes
- array foreign_keys(string $table) - Get foreign keys in table
- array view(string $name) - Get view SELECT
- array collations() - Get sorted grouped list of collations
- bool information_schema(string $db) - Find out if database is information_schema
- string error() - Get escaped error message
- int error_line() - Get line of error
- string exact_value(string $val) - Return expression for binary comparison
- string create_database(string $db, string $collation) - Create database
- bool drop_databases(array $databases) - Drop databases
- bool rename_database(string $name, string $collation) - Rename database from DB
- string auto_increment() - Generate modifier for auto increment column
- bool alter_table(string $table, string $name, array $fields, array $foreign, string $comment, string $engine, string $collation, int $auto_increment, string $partitioning) - Run commands to create or alter table
- bool alter_indexes(string $table, array $alter) - Run commands to alter indexes
- bool truncate_tables(array $tables) - Run commands to truncate tables
- bool drop_views(array $views) - Drop views
- bool drop_tables(array $tables) - Drop tables
- bool move_tables(array $tables, array $views, string $target) - Move tables to other schema
- bool copy_tables(array $tables, array $views, string $target) - Copy tables to other schema
- array trigger(string $name) - Get information about trigger
- array triggers(string $table) - Get defined triggers
- array trigger_options() - Get trigger options
- array routine(string $name, string $type) - Get information about stored routine
- array routines() - Get list of routines
- array routine_languages() - Get list of available routine languages
- bool begin() - Begin transaction
- bool insert_into(string $table, array $set) - Insert data into table
- bool insert_update(string $table, array $set, array $primary) - Insert or update data in the table
- string last_id() - Get last auto increment ID
- Min_Result explain(Min_DB $connection, string $query) - Explain select
- int found_rows(array $table_status, array $where) - Get approximate number of rows
- array types() - Get user defined types
- array schemas() - Get existing schemas
- string get_schema() - Get current schema
- bool set_schema(string $schema) - Set current schema
- string create_sql(string $table, bool $auto_increment) - Get SQL command to create table
- string truncate_sql(string $table) - Get SQL command to truncate table
- string use_sql(string $database) - Get SQL command to change database
- string trigger_sql(string $table, string $style) - Get SQL commands to create triggers
- array show_variables() - Get server variables
- array process_list() - Get process list
- array show_status() - Get status variables
- string convert_field(array $field) - Convert field in select and edit
- string unconvert_field(array $field, string $return) - Convert value in edit after applying functions back
- bool support(string $feature) - Check whether a feature is supported
Adminer specific functions:
- null select(Min_Result $result, Min_DB $connection2, string $href, array $orgtables) - Print select result
- array referencable_primary(string $self) - Get referencable tables with single column primary key except self
- null textarea(string $name, int $value, int $rows, string $cols) - Print SQL <textarea> tag
- string format_time(string $start, string $end) - Format time difference
- null edit_type(string $key, array $field, array $collations, array $foreign_keys) - Print table columns for type edit
- string process_length(string $length) - Filter length value including enums
- string process_type(array $field, string $collate) - Create SQL string from field type
- array process_field(array $field, array $type_field) - Create SQL string from field
- string type_class(string $type) - Get type class to use in CSS
- null edit_fields(array $fields, array $collations, string $type, array $foreign_keys) - Print table interior for fields editing
- null process_fields(array $fields) - Move fields up and down or add field
- string normalize_enum(array $match) - Callback used in routine()
- bool grant(string $grant, array $privileges, string $columns, string $on) - Issue grant or revoke commands
- null drop_create(string $drop, string $create, string $rollback, string $location, string $message_drop, string $message_alter, string $message_create, string $name) - Drop old object and create a new one
- string create_trigger(string $on, array $row) - Generate SQL query for creating trigger
- string create_routine(string $routine, array $row) - Generate SQL query for creating routine
- string remove_definer(string $query) - Remove current user definer from SQL command
- string tar_file(string $filename, string $contents) - Get string to add a file in TAR
- int ini_bytes(string $ini) - Get INI bytes value
Editor specific functions:
- string email_header(string $header) - Encode e-mail header in UTF-8
- bool send_mail(string $email, string $subject, string $message, string $from, array $files) - Send e-mail in UTF-8
- bool like_bool(array $field) - Check whether the column looks like boolean