Exemplo n.º 1
0
}
$tmp = split(":", $_SESSION['ses_database']);
$sys_dbType = 'postgres';
$sys_dbIP = $tmp[0];
$sys_dbPort = $tmp[1];
$sys_dbLogin = $tmp[2];
$sys_dbPass = $tmp[3];
$sys_dbName = $lstParams['db'];
$db = new phpDBConnection($sys_dbType);
$db->connect($sys_dbIP, $sys_dbLogin, $sys_dbPass, $sys_dbName, $sys_dbPort);
require "features.php";
switch ($lstParams['req_name'] . "::" . $lstParams['req_cmd']) {
    case "viewScript::edit_get_data":
        $vw = split("\\.", $lstParams['view']);
        $sql = "SELECT definition FROM pg_views\n\t\t\t\tWHERE viewname = '" . $vw[2] . "'\n\t\t\t\t\tAND schemaname = '" . $vw[1] . "'";
        $rs = $db->execute($sql);
        $sql = $rs->fields[0];
        // -- process edit
        print "document.getElementById('sql').value = \"CREATE OR REPLACE VIEW " . $lstParams['view'] . " AS \\n" . addslashes($sql) . "\";";
        print "top.elements['viewScript'].dataReceived();";
        break;
    case "viewData::lst_get_data":
        $tbl = split("\\.", $lstParams['view']);
        // -- get fields
        $sql = "SELECT * FROM " . $lstParams['view'] . " LIMIT 1";
        $rs = $db->execute($sql);
        $fields = $db->res_fields;
        print "top.elements.viewData.columns = [];\n";
        foreach ($fields as $k => $v) {
            print "top.elements.viewData.addColumn('{$v}', '', 'Text', '');\n";
        }
Exemplo n.º 2
0
     $db_time = round(((double) $t2 - (double) $t1) * 1000) / 1000;
     if (!$rs) {
         $msg = "<span style='color: red'>" . $db->res_errMsg . "</span> ";
     } else {
         $msg = "Query Time: " . $db_time . "<br>Affected Rows: " . $db->res_affectedRows . "<br> Rows Returned: " . $db->res_rowCount . "<br> Fields Returned: " . $db->res_fieldCount . "";
     }
     print $msg;
     print "</textarea>";
     print "<script>\n\t\t\t\twindow.onload = pload;\n\t\t\t\tfunction pload() {\n\t\t\t\t\tparent.document.getElementById('display').innerHTML = '<div style=\"padding: 10px; line-height: 135%;\">'+ document.getElementById('data').value +'</div>';\n\t\t\t\t}\n\t\t\t</script>";
     die;
     break;
 case 'p':
     // -- get fields
     $_SESSION['tmp_sql'] = $sql;
     $sql = "SELECT * FROM ({$sql}) list1 LIMIT 1";
     $rs = $db->execute($sql);
     if (!is_array($db->res_fields)) {
         print "<script>\n\t\t\t\t\twindow.onload = pload;\n\t\t\t\t\tfunction pload() {\n\t\t\t\t\t\tparent.document.getElementById('display').innerHTML = '<div style=\"padding: 10px; color: red;\">" . $db->res_errMsg . "</div>';\n\t\t\t\t\t}\n\t\t\t\t</script>";
         die;
     } else {
         print "<script>\n\t\t\t\t\t\t\twindow.onload = pload;\n\t\t\t\t\t\t\tfunction pload() {";
     }
     // -- list
     $fields = $db->res_fields;
     print "top.elements.execData.columns = [];\n";
     foreach ($fields as $k => $v) {
         print "top.elements.execData.addColumn('{$v}', '', 'Text', '');\n";
     }
     // -- edit
     print "top.elements.execDataAdd.fieldIndex = 0;\n" . "top.elements.execDataAdd.groups[0].fields = [];\n" . "var group = top.elements.execDataAdd.groups[0];\n";
     foreach ($fields as $k => $v) {