Skip to content

Instantly share code, notes, and snippets.

@alixaxel
Created January 19, 2013 21:39
Show Gist options
  • Save alixaxel/4575374 to your computer and use it in GitHub Desktop.
Save alixaxel/4575374 to your computer and use it in GitHub Desktop.
Collection of Adminer Plugins
<?php
/** plugin_DatabaseHide.php
* @author Alix Axel
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
class AdminerDatabaseHide {
protected $disabled;
function AdminerDatabaseHide($disabled) {
$this->disabled = $disabled;
}
function databases($flush = true) {
return preg_grep('~' . $this->disabled . '~i', get_databases($flush), PREG_GREP_INVERT);
}
}
<?php
/** plugin_ForeignConvention.php
* @author Alix Axel
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
class AdminerForeignConvention {
function foreignKeys($table) {
$result = array();
foreach (preg_grep('~^id_|_id$~', array_keys(fields($table))) as $field) {
$result[] = array('table' => preg_replace('~^id_|_id$~', '', $field), 'source' => array($field), 'target' => array('id'));
}
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment