Ejemplo n.º 1
0
     }
     if (!isset($_REQUEST['fix'])) {
         $output .= '<form><input type="hidden" name="action" value="exec"/><textarea name="sqlcmd" cols="80">' . $sqlcmd . '</textarea><br/><input type="submit" value="Ejecutar SQL"></form>';
     } else {
         $output .= "SQL Aplicado: " . $sqlcmd;
     }
     if ($sqlcmd) {
         $data = new Data();
         $data->execSql($sqlcmd);
         $sqldata = $data->getArray();
         $output .= "<pre>" . print_r($sqldata, 1) . "</pre>";
     }
     break;
 case 'sql':
     foreach ($tables as $key) {
         $output .= genSQL($key);
     }
     break;
 case 'dd':
     foreach ($tables as $key) {
         $dd = genDD($key);
         $output .= "\n" . '<tr align="center"><td colspan="5" bgcolor="#f0f0f0"><br/>' . getTitle($key) . " ({$key})</br><br/></td></tr>\n";
         $output .= "\n<tr><th>Nombre</th><th>Tipo</th><th>Tama&ntilde;o</th><th>Referencias</th><th>Descripci&oacute;n</th></tr>\n";
         foreach ($dd as $col) {
             $color = $col[5] ? '#bbbbbb' : '#ffffff';
             unset($col[5]);
             unset($col[6]);
             $output .= "<tr bgcolor=\"{$color}\">";
             foreach ($col as $val) {
                 $output .= "<td>{$val}&nbsp;</td>";
             }
Ejemplo n.º 2
0
<?php

global $global_dd;
# Aplica a BD SQL los cambios necesarios
require_once 'setup.gensql.php';
$dbtype = $this->dbtype;
$sqlcmd = "SELECT {$this->table_fields} FROM {$this->name} LIMIT 1";
@$this->execSql($sqlcmd);
$sql_fix = '';
if (almdata::isError($this->data)) {
    #$existe = $this->catalogTableExists($this->name);
    $sqlcmd = "SELECT * FROM {$this->name} LIMIT 1";
    @$this->execSql($sqlcmd);
    if (almdata::isError($this->data)) {
        $sql_fix = genSQL($this->name);
        $this->execSql($sql_fix);
        echo "AUTO SQL {$sql_fix}<br/>\n";
    } else {
        $campos = preg_split('/,/', $this->table_fields);
        foreach ($campos as $campo) {
            #$existe = $this->catalogColumnExists($campo['name']);
            $sqlcmd = "SELECT {$campo} FROM {$this->name} LIMIT 1";
            @$this->execSql($sqlcmd);
            if (almdata::isError($this->data)) {
                list($tmp, $campo) = preg_split('/\\./', $campo);
                $size = isset($this->dd[$campo]['size']) && $this->dd[$campo]['size'] > 0 ? '(' . $this->dd[$campo]['size'] . ')' : '';
                if (!isset($this->key)) {
                    $this->key = false;
                }
                if (!isset($global_dd[$campo])) {
                    $global_dd[$campo] = null;