Ejemplo n.º 1
0
 function editInput($table, $field, $attrs, $value)
 {
     static $foreignTables = array();
     static $values = array();
     $foreignKeys =& $foreignTables[$table];
     if ($foreignKeys === null) {
         $foreignKeys = column_foreign_keys($table);
     }
     foreach ((array) $foreignKeys[$field["field"]] as $foreignKey) {
         if (count($foreignKey["source"]) == 1) {
             $target = $foreignKey["table"];
             $id = $foreignKey["target"][0];
             $options =& $values[$target][$id];
             if (!$options) {
                 $options = array("" => "") + get_vals("SELECT " . idf_escape($id) . " FROM " . table($target) . " ORDER BY 1");
             }
             return "<select{$attrs}>" . optionlist($options, $value) . "</select>";
         }
     }
 }
Ejemplo n.º 2
0
<?php

$TABLE = $_GET["select"];
$table_status = table_status($TABLE);
$indexes = indexes($TABLE);
$fields = fields($TABLE);
$foreign_keys = column_foreign_keys($TABLE);
$oid = "";
if ($table_status["Oid"] == "t") {
    $oid = $jush == "sqlite" ? "rowid" : "oid";
    $indexes[] = array("type" => "PRIMARY", "columns" => array($oid));
}
parse_str($_COOKIE["adminer_import"], $adminer_import);
$rights = array();
// privilege => 0
$columns = array();
// selectable columns
$text_length = null;
foreach ($fields as $key => $field) {
    $name = $adminer->fieldName($field);
    if (isset($field["privileges"]["select"]) && $name != "") {
        $columns[$key] = html_entity_decode(strip_tags($name));
        if (ereg('text|lob|geometry|point|linestring|polygon', $field["type"])) {
            $text_length = $adminer->selectLengthProcess();
        }
    }
    $rights += $field["privileges"];
}
list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes);
$is_group = count($group) < count($select);
$where = $adminer->selectSearchProcess($fields, $indexes);
Ejemplo n.º 3
0
<?php

if ($_GET["script"] == "kill") {
    $connection->query("KILL " . +$_POST["kill"]);
} elseif (list($table, $id, $name) = $adminer->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) {
    $limit = 11;
    $result = $connection->query("SELECT {$id}, {$name} FROM " . table($table) . " WHERE " . (preg_match('~^[0-9]+$~', $_GET["value"]) ? "{$id} = {$_GET['value']} OR " : "") . "{$name} LIKE " . q("{$_GET['value']}%") . " ORDER BY 2 LIMIT {$limit}");
    for ($i = 1; ($row = $result->fetch_row()) && $i < $limit; $i++) {
        echo "<a href='" . h(ME . "edit=" . urlencode($table) . "&where" . urlencode("[" . bracket_escape(idf_unescape($id)) . "]") . "=" . urlencode($row[0])) . "'>" . h($row[1]) . "</a><br>\n";
    }
    if ($row) {
        echo "...\n";
    }
}
exit;
// don't print footer