public function awaken()
 {
     // should we use Redis?
     $this->useRedis = isset($_POST['use_redis']);
     if (!$this->useRedis) {
         // SQL not supported with Zend DB adapter anymore.
         // get list of tables
         $db = \Zule\Tools\DB::zdb();
         $dbTables = $db->listTables();
         foreach ($dbTables as $table) {
             if (in_array($table, array_keys($_POST))) {
                 $this->tables[] = new ModelTable($table);
             }
         }
         return $this;
     } else {
         // not sure what to do here.
         return $this;
     }
 }
 public function awaken()
 {
     // Get database columns & primary keys
     $db = \Zule\Tools\DB::zdb();
     foreach ($db->describeTable($this->tableName) as $column) {
         if (in_array($this->tableName . '_' . $column['COLUMN_NAME'], array_keys($_POST))) {
             // column wants getters/setters
             $col = $column['COLUMN_NAME'];
             $this->columns[$col] = ['name' => $col, 'camel' => camel($col), 'l_camel' => lCamel($col)];
             if ($column['PRIMARY']) {
                 $this->primaryKeys[] = $col;
             }
         } else {
             if ($column['PRIMARY']) {
                 // no getter/setter set for primary, but gateway still exists
                 $this->primaryKeys[] = $column['COLUMN_NAME'];
             }
         }
     }
     return $this;
 }
    }
    return $name;
}
function lCamel($name)
{
    while ($pos = strpos($name, '_')) {
        $f = substr($name, 0, $pos);
        $l = substr($name, $pos + 1);
        $l[0] = strtoupper($l[0]);
        $name = $f . $l;
    }
    return $name;
}
$namespace = \Zule\Tools\Config::zc()->framework->application_namespace;
$system = 'Zule';
$db = \Zule\Tools\DB::zdb();
$dbTables = $db->listTables();
foreach ($_POST as $table => $useless) {
    if (in_array($table, $dbTables)) {
        echo "Generating model file for {$table}" . PHP_EOL;
        // $table is scheduled for generation
        $s = new \Smarty();
        $model = $_POST["class_{$table}"];
        $s->assign('model_name', $model);
        $s->assign('namespace', $namespace);
        $s->assign('system', $system);
        $s->assign('php_open', '<?php');
        $columns = [];
        $camels = [];
        $lCamels = [];
        foreach ($db->describeTable($table) as $column) {