function controller_orm($args) { /* if (!User::authorized("orm")) throw new Exception("not allowed"); */ $ret = $this->GetComponentResponse("./orm.tpl"); /* $user = User::singleton(); if (!($user->isLoggedIn() && $user->HasRole("ORM"))) // display the access violation message $ret->SetTemplate("access_violation.tpl"); */ if (!empty($args["ormaction"]) && !empty($args["model"])) { $ret["model"] = $args["model"]; $ret["ormcfg"] = new OrmModel($args["model"]); if ($args["ormaction"] == "create" && !empty($args["classname"])) { $ormclass = new OrmClass($ret["ormcfg"]->classes->{$args["classname"]}); //$sql = $ormclass->getCreateSql(); $sqlkey = "db." . $ormclass->table . ".create:nocache"; /* print_pre($ormclass->table); print_pre($ormclass->getColumns()); */ $outlet = Outlet::getInstance(); $pdo = $outlet->getConnection()->getPDO(); if ($pdo) { $ret["sql"] = $ormclass->getCreateSQL(); try { $pdo->query($ret["sql"]); $ret["success"] = "Table '{$ormclass->table}' created successfully"; } catch (Exception $e) { $ret["error"] = $e->getMessage(); } } /* $data = DataManager::singleton(); $data->QueryCreate($sqlkey, $ormclass->table, $ormclass->getColumns($sql)); */ } } return $ret; }