Example #1
0
     $sqlcmd = "SELECT relname FROM pg_class WHERE  pg_class.relkind = 'r' AND pg_class.relname LIKE 'alm_%'";
 } elseif ($type == 'mysql') {
     $sqlcmd = "SHOW TABLES LIKE 'alm_%'";
 }
 $var = $data->getList($sqlcmd);
 if (count($var) >= 5) {
     $output .= '<br/>Tablas de almidon ya existen. Re-generando solo meta-datos.<br/>';
     $data->execSql("DELETE FROM alm_access");
     $data->execSql("DELETE FROM alm_column");
     $data->execSql("DELETE FROM alm_table");
 } else {
     $data->execSql($alm_sqlcmd);
     $output = "BD Almidonizada!<br/>Codigo SQL aplicado:<br/><pre>{$alm_sqlcmd}</pre><br/>";
 }
 $alm_table = new alm_tableTable();
 $alm_column = new alm_columnTable();
 # Nota: no hay soporte para TableDoubleKey yet...
 $rank = 1;
 $output .= "Re-generando: ";
 foreach ($tables as $key) {
     $keyTable = $key . 'Table';
     $data = new $keyTable();
     $alm_column->execSql("DELETE FROM alm_column WHERE idalm_table='{$key}'");
     $alm_table->deleteRecord($key);
     $alm_table->request['idalm_table'] = $key;
     $alm_table->request['pkey'] = $data->key;
     $alm_table->request['alm_table'] = $data->title;
     $alm_table->request['orden'] = $data->order;
     $alm_table->request['rank'] = $rank;
     if (isset($data->hidden)) {
         $alm_table->request['hidden'] = $data->hidden;
<?php

$alm_table = new alm_tableTable();
$alm_column = new alm_columnTable();
$table_data = $alm_table->readData();
if (!isset($output)) {
    $output = '';
}
foreach ($table_data as $table_datum) {
    $output .= "class " . $table_datum['idalm_table'] . "Table extends Table {\n";
    $output .= "  function " . $table_datum['idalm_table'] . "Table() {\n";
    $output .= "    \$this->Table('" . $table_datum['idalm_table'] . "');\n";
    $hidden = $table_datum['hidden'] == 't' ? 'true' : 'false';
    if ($hidden === 'true') {
        $output .= "    \$this->hidden = " . $hidden . ";\n";
    }
    if (!empty($table_datum['parent'])) {
        $output .= "    \$this->parent ='" . $table_datum['parent'] . "';\n";
    }
    if (!empty($table_datum['child'])) {
        $output .= "    \$this->child ='" . $table_datum['child'] . "';\n";
    }
    if (!empty($table_datum['restrictby'])) {
        $output .= "    if (\$_SESSION['idalm_role'] !== 'full') \$this->filter = \"" . $table_datum['idalm_table'] . '.' . $table_datum['restrictby'] . "='\".\$_SESSION['idalm_user'].\"'\";\n";
    }
    $output .= "    \$this->title ='" . $table_datum['alm_table'] . "';\n";
    if (!empty($table_datum['orden'])) {
        $output .= "    \$this->order ='" . $table_datum['orden'] . "';\n";
    }
    $data = $alm_column->readDataFilter("alm_column.idalm_table='" . $table_datum['idalm_table'] . "'");
    if ($data) {