Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 32 lines (28 sloc) 1.047 kB
08e70e6 @vrana Edit foreign plugin
authored
1 <?php
2
3 /** Select foreign key in edit form
091a4d0 @vrana Link to documentation
authored
4 * @link http://www.adminer.org/plugins/#use
08e70e6 @vrana Edit foreign plugin
authored
5 * @author Jakub Vrana, http://www.vrana.cz/
6 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
8 */
9 class AdminerEditForeign {
10
11 function editInput($table, $field, $attrs, $value) {
12 static $foreignTables = array();
13 static $values = array();
14 $foreignKeys = &$foreignTables[$table];
6591d48 @vrana Replace isset($var) by $var !== null
authored
15 if ($foreignKeys === null) {
08e70e6 @vrana Edit foreign plugin
authored
16 $foreignKeys = column_foreign_keys($table);
17 }
18 foreach ((array) $foreignKeys[$field["field"]] as $foreignKey) {
19 if (count($foreignKey["source"]) == 1) {
20 $target = $foreignKey["table"];
21 $id = $foreignKey["target"][0];
22 $options = &$values[$target][$id];
23 if (!$options) {
24 $options = array("" => "") + get_vals("SELECT " . idf_escape($id) . " FROM " . table($target) . " ORDER BY 1");
25 }
26 return "<select$attrs>" . optionlist($options, $value) . "</select>";
27 }
28 }
29 }
30
31 }
Something went wrong with that request. Please try again.