Exemple #1
0
                        if (strlen($field["field"])) {
                            $set[] = (in_array($field["inout"], $inout) ? "{$field['inout']} " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
                        }
                    }
                    if ($mysql->query("CREATE {$routine} " . idf_escape($_POST["name"]) . " (" . implode(", ", $set) . ")" . (isset($_GET["function"]) ? " RETURNS" . process_type($_POST["returns"], "CHARACTER SET") : "") . "\n\t\t\t{$_POST['definition']}")) {
                        redirect(substr($SELF, 0, -1), strlen($_GET["procedure"]) ? lang('Routine has been altered.') : lang('Routine has been created.'));
                    }
                }
                $error = $mysql->error;
            }
            page_header(strlen($_GET["procedure"]) ? (isset($_GET["function"]) ? lang('Alter function') : lang('Alter procedure')) . ": " . htmlspecialchars($_GET["procedure"]) : (isset($_GET["function"]) ? lang('Create function') : lang('Create procedure')), $error);
            $collations = get_vals("SHOW CHARACTER SET");
            if ($_POST) {
                $row = $_POST;
                $row["fields"] = (array) $row["fields"];
                process_fields($row["fields"]);
            } elseif (strlen($_GET["procedure"])) {
                $row = routine($_GET["procedure"], $routine);
                $row["name"] = $_GET["procedure"];
            } else {
                $row = array("fields" => array());
            }
            ?>

<form action="" method="post" id="form">
<table border="0" cellspacing="0" cellpadding="2">
<?php 
            edit_fields($row["fields"], $collations, $routine);
            if (isset($_GET["function"])) {
                ?>
<tr><td><?php 
Exemple #2
0
}
$orig_fields = array();
$table_status = array();
if ($TABLE != "") {
    $orig_fields = fields($TABLE);
    $table_status = table_status($TABLE);
    if (!$table_status) {
        $error = lang('No tables.');
    }
}
$row = $_POST;
$row["fields"] = (array) $row["fields"];
if ($row["auto_increment_col"]) {
    $row["fields"][$row["auto_increment_col"]]["auto_increment"] = true;
}
if ($_POST && !process_fields($row["fields"]) && !$error) {
    if ($_POST["drop"]) {
        queries_adminer_redirect(substr(ME, 0, -1), lang('Table has been dropped.'), drop_tables(array($TABLE)));
    } else {
        $fields = array();
        $all_fields = array();
        $use_all_fields = false;
        $foreign = array();
        ksort($row["fields"]);
        $orig_field = reset($orig_fields);
        $after = " FIRST";
        foreach ($row["fields"] as $key => $field) {
            $foreign_key = $foreign_keys[$field["type"]];
            $type_field = $foreign_key !== null ? $referencable_primary[$foreign_key] : $field;
            //! can collide with user defined type
            if ($field["field"] != "") {
<?php

$fp = fopen('fixed-width-records.txt', 'r', true) or die("can't open file");
while ($s = fgets($fp, 1024)) {
    $fields[1] = substr($s, 0, 25);
    // first field:  first 25 characters of the line
    $fields[2] = substr($s, 25, 15);
    // second field: next 15 characters of the line
    $fields[3] = substr($s, 40, 4);
    // third field:  next 4 characters of the line
    $fields = array_map('rtrim', $fields);
    // strip the trailing whitespace
    // a function to do something with the fields
    process_fields($fields);
}
fclose($fp) or die("can't close file");