Example #1
0
/**
 * This is a callback function to display the result of each separate query
 * @param ADORecordSet $rs The recordset returned by the script execetor
 */
function sqlCallback($query, $rs, $lineno)
{
    global $data, $misc, $lang, $_connection;
    // Check if $rs is false, if so then there was a fatal error
    if ($rs === false) {
        echo htmlspecialchars($_FILES['script']['name']), ':', $lineno, ': ', nl2br(htmlspecialchars($_connection->getLastError())), "<br/>\n";
    } else {
        // Print query results
        switch (pg_result_status($rs)) {
            case PGSQL_TUPLES_OK:
                // If rows returned, then display the results
                $num_fields = pg_numfields($rs);
                echo "<p><table>\n<tr>";
                for ($k = 0; $k < $num_fields; $k++) {
                    echo "<th class=\"data\">", $misc->printVal(pg_fieldname($rs, $k)), "</th>";
                }
                $i = 0;
                $row = pg_fetch_row($rs);
                while ($row !== false) {
                    $id = $i % 2 == 0 ? '1' : '2';
                    echo "<tr class=\"data{$id}\">\n";
                    foreach ($row as $k => $v) {
                        echo "<td style=\"white-space:nowrap;\">", $misc->printVal($v, pg_fieldtype($rs, $k), array('null' => true)), "</td>";
                    }
                    echo "</tr>\n";
                    $row = pg_fetch_row($rs);
                    $i++;
                }
                echo "</table><br/>\n";
                echo $i, " {$lang['strrows']}</p>\n";
                break;
            case PGSQL_COMMAND_OK:
                // If we have the command completion tag
                if (version_compare(phpversion(), '4.3', '>=')) {
                    echo htmlspecialchars(pg_result_status($rs, PGSQL_STATUS_STRING)), "<br/>\n";
                } elseif ($data->conn->Affected_Rows() > 0) {
                    echo $data->conn->Affected_Rows(), " {$lang['strrowsaff']}<br/>\n";
                }
                // Otherwise output nothing...
                break;
            case PGSQL_EMPTY_QUERY:
                break;
            default:
                break;
        }
    }
}
 function IsTimestamp($vField)
 {
     // FIXME
     // substr because it could be timestamp or timestamptz
     return $this->res > 0 && substr(pg_fieldtype($this->res, $vField), 0, 9) == 'timestamp';
 }
 function field_type($result, $int)
 {
     $fieldtype = pg_fieldtype($result, $int);
     #echo $fieldtype.", ".$fieldlen."<br>";
     #if ( strstr($fieldtype, "char") ) $fieldtype = "string";
     #if ( $fieldtype == "text" ) $fieldtype = "blob";
     return $fieldtype;
 }
Example #4
0
 function sql_fieldtype($offset, $query_id = 0)
 {
     if (!$query_id) {
         $query_id = $this->query_result;
     }
     return $query_id ? @pg_fieldtype($query_id, $offset) : false;
 }
Example #5
0
 /**
  * Returns information about a table or a result set
  *
  * NOTE: doesn't support table name and flags if called from a db_result
  *
  * @param  mixed $resource PostgreSQL result identifier or table name
  * @param  int $mode A valid tableInfo mode (DB_TABLEINFO_ORDERTABLE or
  *                   DB_TABLEINFO_ORDER)
  *
  * @return array An array with all the information
  */
 function tableInfo($result, $mode = null)
 {
     $count = 0;
     $id = 0;
     $res = array();
     /*
      * depending on $mode, metadata returns the following values:
      *
      * - mode is false (default):
      * $result[]:
      *   [0]["table"]  table name
      *   [0]["name"]   field name
      *   [0]["type"]   field type
      *   [0]["len"]    field length
      *   [0]["flags"]  field flags
      *
      * - mode is DB_TABLEINFO_ORDER
      * $result[]:
      *   ["num_fields"] number of metadata records
      *   [0]["table"]  table name
      *   [0]["name"]   field name
      *   [0]["type"]   field type
      *   [0]["len"]    field length
      *   [0]["flags"]  field flags
      *   ["order"][field name]  index of field named "field name"
      *   The last one is used, if you have a field name, but no index.
      *   Test:  if (isset($result['meta']['myfield'])) { ...
      *
      * - mode is DB_TABLEINFO_ORDERTABLE
      *    the same as above. but additionally
      *   ["ordertable"][table name][field name] index of field
      *      named "field name"
      *
      *      this is, because if you have fields from different
      *      tables with the same field name * they override each
      *      other with DB_TABLEINFO_ORDER
      *
      *      you can combine DB_TABLEINFO_ORDER and
      *      DB_TABLEINFO_ORDERTABLE with DB_TABLEINFO_ORDER |
      *      DB_TABLEINFO_ORDERTABLE * or with DB_TABLEINFO_FULL
      */
     // if $result is a string, then we want information about a
     // table without a resultset
     if (is_string($result)) {
         $id = pg_exec($this->connection, "SELECT * FROM {$result}");
         if (empty($id)) {
             return $this->pgsqlRaiseError();
         }
     } else {
         // else we want information about a resultset
         $id = $result;
         if (empty($id)) {
             return $this->pgsqlRaiseError();
         }
     }
     $count = @pg_numfields($id);
     // made this IF due to performance (one if is faster than $count if's)
     if (empty($mode)) {
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = is_string($result) ? $result : '';
             $res[$i]['name'] = @pg_fieldname($id, $i);
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = is_string($result) ? $this->_pgFieldflags($id, $i, $result) : '';
         }
     } else {
         // full
         $res["num_fields"] = $count;
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = is_string($result) ? $result : '';
             $res[$i]['name'] = @pg_fieldname($id, $i);
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = is_string($result) ? $this->_pgFieldFlags($id, $i, $result) : '';
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
     }
     // free the result only if we were called on a table
     if (is_resource($id)) {
         @pg_freeresult($id);
     }
     return $res;
 }
/**                                                       
 * Get the type of the specified field  
 *
 *  @param		$lhandle	(string) Query result set handle
 *  @param		$fnumber (int)	Column number
 */
function db_field_type($lhandle, $fnumber)
{
    return @pg_fieldtype($lhandle, $fnumber);
}
Example #7
0
function vty_field_type($list,$i){
        switch($this->vtAdi){
        case 'mysql': return mysql_field_type($list,$i); break;
        case 'odbc': return odbc_field_type($list,$i); break;
        case 'mssql': return mssql_field_type($list,$i); break;
        case 'postgresql': pg_fieldtype($list,$i); break;
        }
}
Example #8
0
 /**
  * Returns information about a table or a result set.
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * @param object|string  $result  DB_result object from a query or a
  *                                string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  * @return array  an associative array with the information requested
  *                or an error object if something is wrong
  * @access public
  * @internal
  * @see DB_common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if (isset($result->result)) {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->result;
         $got_string = false;
     } elseif (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $id = @pg_exec($this->connection, "SELECT * FROM {$result} LIMIT 0");
         $got_string = true;
     } else {
         /*
          * Probably received a result resource identifier.
          * Copy it.
          * Deprecated.  Here for compatibility only.
          */
         $id = $result;
         $got_string = false;
     }
     if (!is_resource($id)) {
         return $this->pgsqlRaiseError(DB_ERROR_NEED_MORE_DATA);
     }
     if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     $count = @pg_numfields($id);
     // made this IF due to performance (one if is faster than $count if's)
     if (!$mode) {
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $got_string ? $case_func($result) : '';
             $res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = $got_string ? $this->_pgFieldflags($id, $i, $result) : '';
         }
     } else {
         // full
         $res['num_fields'] = $count;
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $got_string ? $case_func($result) : '';
             $res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = $got_string ? $this->_pgFieldFlags($id, $i, $result) : '';
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
     }
     // free the result only if we were called on a table
     if ($got_string) {
         @pg_freeresult($id);
     }
     return $res;
 }
Example #9
0
<?php

include 'config.inc';
$db = pg_connect($conn_str);
$result = pg_exec("SELECT * FROM " . $table_name);
pg_numrows($result);
pg_numfields($result);
pg_fieldname($result, 0);
pg_fieldsize($result, 0);
pg_fieldtype($result, 0);
pg_fieldprtlen($result, 0);
pg_fieldisnull($result, 0);
pg_result($result, 0, 0);
$result = pg_exec("INSERT INTO " . $table_name . " VALUES (7777, 'KKK')");
$oid = pg_getlastoid($result);
pg_freeresult($result);
pg_errormessage();
$result = pg_exec("UPDATE " . $table_name . " SET str = 'QQQ' WHERE str like 'RGD';");
pg_cmdtuples($result);
echo "OK";
function db_lovrot($query, $numlinhas, $arquivo = "", $filtro = "%", $aonde = "_self", $campos_layer = "", $NomeForm = "NoMe", $variaveis_repassa = array(), $automatico = true, $totalizacao = array())
{
    //Observação : Quando utilizar o parametro automatico, coloque no parametro NomeForm o seguinte "NoMe" e em variaveis_repassa array().
    //#00#//db_lovrot
    //#10#//Esta funcao é utilizada para mostrar registros na tela, podendo páginar os dados
    //#15#//db_lovrot($query,$numlinhas,$arquivo="",$filtro="%",$aonde="_self",$campos_layer="",$NomeForm="NoMe",$variaveis_repassa=array());
    //#20#//$query               Select que será executado
    //#20#//$numlinhas           Número de linhas a serem mostradas
    //#20#//$arquivo             Arquivo que será executado quando der um click em uma linha
    //#20#//                     Na versão com iframe deverá ser colocado "()"
    //#20#//$filtro              Filtro que será gerado, normamente ""
    //#20#//$aonde               Nome da função que será executada quando der um click
    //#20#//$campos_layer        Campos que serão colocados na layer quando passar o mouse ( não esta implementado )
    //#20#//$NomeForm            Nome do formulário para colocar variáveis complementares Padrão = "NoMe"
    //#20#//$variaveis_repassa   Array com as variáveis a serem reoassadas para o programa
    //#99#//Exemplo:
    //#99#//$js_funcao = "";
    //#99#//db_lovrot("select z01_nome from cgm limit 1","()","",$js_funcao);
    //#99#//
    //#99#//O cabeçalho da tabela o sistema pega pelo nome do campo e busca na documentação, colcando o label
    //#99#//Quando não desejar colocar o label da documentacao, o nome do campo deverá ser iniciado com dl_ e o sistema retirará
    //#99#//estes caracteres e colocará o primeiro caracter em maiusculo
    //#99#//Criado parametro novo, $totalizacao = array() que devere fornecer os campos que desejar fazer somatorio, conforme
    //#99#//exemplo abaixo:
    //#99#//
    //#99#//$totalizacao["e60_vlremp"] = "e60_vlremp"; totaliza o campo
    //#99#//$totalizacao["e60_vlranu"] = "e60_vlranu"; totaliza o campo
    //#99#//$totalizacao["e60_vlrpag"] = "e60_vlrpag"; totaliza o campo
    //#99#//$totalizacao["e60_vlrliq"] = "e60_vlrliq"; totaliza o campo
    //#99#//$totalizacao["dl_saldo"] = "dl_saldo";     totaliza o campo ( neste caso, o campo é um alias no sql)
    //#99#//$totalizacao["totalgeral"] = "z01_nome";   indica qual o campo sera colocado o total
    global $BrowSe;
    //cor do cabecalho
    global $db_corcabec;
    $db_corcabec = $db_corcabec == "" ? "#CDCDFF" : $db_corcabec;
    //cor de fundo de cada registro
    global $cor1;
    global $cor2;
    $cor1 = $GLOBALS['w01_corfundomenu'];
    $cor2 = $GLOBALS['w01_corfundomenuativo'];
    $mensagem = "Clique Aqui";
    $cor1 = $cor1 == "" ? "#97B5E6" : $cor1;
    $cor2 = $cor2 == "" ? "#E796A4" : $cor2;
    global $HTTP_POST_VARS;
    $tot_registros = "tot_registros" . $NomeForm;
    $offset = "offset" . $NomeForm;
    //recebe os valores do campo hidden
    if (isset($HTTP_POST_VARS["totreg" . $NomeForm])) {
        ${$tot_registros} = $HTTP_POST_VARS["totreg" . $NomeForm];
    } else {
        ${$tot_registros} = 0;
    }
    if (isset($HTTP_POST_VARS["offset" . $NomeForm])) {
        ${$offset} = $HTTP_POST_VARS["offset" . $NomeForm];
    } else {
        ${$offset} = 0;
    }
    if (isset($HTTP_POST_VARS["recomecar"])) {
        $recomecar = $HTTP_POST_VARS["recomecar"];
    }
    // se for a primeira vez que é rodado, pega o total de registros e guarda no campo hidden
    if (empty(${$tot_registros}) && !empty($query) || isset($recomecar)) {
        if (isset($recomecar)) {
            $query = db_getsession("dblov_query_inicial");
        }
        $Dd1 = "disabled";
        if (count($totalizacao) > 0 || isset($totalizacao_rep)) {
            $total_campos = "";
            $sep_total_campos = "";
            reset($totalizacao);
            for ($j = 0; $j < count($totalizacao); $j++) {
                if (key($totalizacao) == $totalizacao[key($totalizacao)]) {
                    $total_campos .= $sep_total_campos . "sum(" . $totalizacao[key($totalizacao)] . ") as " . $totalizacao[key($totalizacao)];
                    $sep_total_campos = ",";
                }
                next($totalizacao);
            }
            reset($totalizacao);
            $tot = db_query("select count(*),{$total_campos}\n\tfrom ({$query}) as temp");
        } else {
            $tot = db_query("select count(*) from ({$query}) as temp");
        }
        //$tot = 0;
        db_putsession("dblov_query_inicial", $query);
        ${$tot_registros} = pg_result($tot, 0, 0);
        if (${$tot_registros} == 0) {
            $Dd2 = "disabled";
        }
    }
    if (isset($HTTP_POST_VARS["nova_quantidade_linhas"]) && $HTTP_POST_VARS["nova_quantidade_linhas"] != '') {
        $HTTP_POST_VARS["nova_quantidade_linhas"] = $HTTP_POST_VARS["nova_quantidade_linhas"] + 0;
        $numlinhas = $HTTP_POST_VARS["nova_quantidade_linhas"];
    }
    // testa qual botao foi pressionado
    if (isset($HTTP_POST_VARS["pri" . $NomeForm])) {
        ${$offset} = 0;
        $Dd1 = "disabled";
        $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
    } else {
        if (isset($HTTP_POST_VARS["ant" . $NomeForm])) {
            // if(isset("filtroquery"]);
            $query = str_replace("\\", "", @$HTTP_POST_VARS["filtroquery"]);
            if (${$offset} <= $numlinhas) {
                ${$offset} = 0;
                $Dd1 = "disabled";
            } else {
                ${$offset} = ${$offset} - $numlinhas;
            }
        } else {
            if (isset($HTTP_POST_VARS["prox" . $NomeForm])) {
                $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
                //    if($numlinhas >= ($$tot_registros - $$offset - $numlinhas)) {
                if (${$offset} + $numlinhas * 2 >= ${$tot_registros}) {
                    $Dd2 = "disabled";
                }
                if ($numlinhas >= ${$tot_registros} - ${$offset}) {
                    //$$offset = $$tot_registros - $numlinhas;
                    if (${$tot_registros} - ${$offset} - $numlinhas >= $numlinhas) {
                        ${$offset} = $numlinhas;
                    } else {
                        ${$offset} = ${$offset} + $numlinhas;
                    }
                    if (${$offset} > ${$tot_registros}) {
                        ${$offset} = 0;
                    }
                    $Dd2 = "disabled";
                } else {
                    ${$offset} = ${$offset} + $numlinhas;
                }
            } else {
                if (isset($HTTP_POST_VARS["ult" . $NomeForm])) {
                    $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
                    ${$offset} = ${$tot_registros} - $numlinhas;
                    if (${$offset} < 0) {
                        ${$offset} = 0;
                    }
                    $Dd2 = "disabled";
                } else {
                    reset($HTTP_POST_VARS);
                    for ($i = 0; $i < sizeof($HTTP_POST_VARS); $i++) {
                        $ordem_lov = substr(key($HTTP_POST_VARS), 0, 11);
                        if ($ordem_lov == 'ordem_dblov') {
                            $query = str_replace("\\", "", $HTTP_POST_VARS["filtroquery"]);
                            $campo = substr(key($HTTP_POST_VARS), 11);
                            $ordem_ordenacao = '';
                            if (isset($HTTP_POST_VARS['ordem_lov_anterior'])) {
                                if ($HTTP_POST_VARS['ordem_lov_anterior'] == $HTTP_POST_VARS[key($HTTP_POST_VARS)]) {
                                    $ordem_ordenacao = 'desc';
                                }
                            }
                            if ($HTTP_POST_VARS["codigo_pesquisa"] != '') {
                                $query_anterior = $query;
                                $query_novo_filtro = "select * from (" . $query . ") as x where " . $campo . " ILIKE '" . $HTTP_POST_VARS["codigo_pesquisa"] . "%' order by " . $campo . ' ' . $ordem_ordenacao;
                                $query = $query_novo_filtro;
                            } else {
                                if ($HTTP_POST_VARS["distinct_pesquisa"] == '1') {
                                    $query_anterior = $query;
                                    $query = "select distinct on (" . $campo . ") * from (" . $query . ") as x order by " . $campo . " " . $ordem_ordenacao;
                                    $query_novo_filtro = $query;
                                } else {
                                    $query = "select * from (" . $query . ") as x order by " . $campo . " " . $ordem_ordenacao;
                                }
                            }
                            ${$offset} = 0;
                            break;
                        }
                        next($HTTP_POST_VARS);
                    }
                }
            }
        }
    }
    $filtroquery = $query;
    // executa a query e cria a tabela
    if ($query == "") {
        exit;
    }
    $query .= " limit {$numlinhas} offset " . ${$offset};
    $result = db_query($query);
    $NumRows = pg_numrows($result);
    if ($NumRows == 0) {
        if (isset($query_anterior)) {
            echo "<script>alert('Não existem dados para este filtro');</script>";
            if (count($totalizacao) > 0 || isset($totalizacao_rep)) {
                $total_campos = "";
                $sep_total_campos = "";
                reset($totalizacao);
                for ($j = 0; $j < count($totalizacao); $j++) {
                    if (key($totalizacao) == $totalizacao[key($totalizacao)]) {
                        $total_campos .= $sep_total_campos . "sum(" . $totalizacao[key($totalizacao)] . ") as " . $totalizacao[key($totalizacao)];
                        $sep_total_campos = ",";
                    }
                    next($totalizacao);
                }
                reset($totalizacao);
                $tot = db_query("select count(*),{$total_campos}\n                            from ({$query_anterior}) as temp");
            } else {
                $tot = db_query("select count(*) from ({$query_anterior}) as temp");
            }
            //$tot = 0;
            ${$tot_registros} = pg_result($tot, 0, 0);
            ${$tot_registros} = pg_result($tot, 0, 0);
            $query = $query_anterior . " limit {$numlinhas} offset " . ${$offset};
            $result = db_query($query);
            $NumRows = pg_numrows($result);
            $filtroquery = $query_anterior;
        }
    } else {
        if (isset($query_anterior)) {
            $Dd1 = "disabled";
            if (count($totalizacao) > 0 || isset($totalizacao_rep)) {
                $total_campos = "";
                $sep_total_campos = "";
                reset($totalizacao);
                for ($j = 0; $j < count($totalizacao); $j++) {
                    if (key($totalizacao) == $totalizacao[key($totalizacao)]) {
                        $total_campos .= $sep_total_campos . "sum(" . $totalizacao[key($totalizacao)] . ") as " . $totalizacao[key($totalizacao)];
                        $sep_total_campos = ",";
                    }
                    next($totalizacao);
                }
                reset($totalizacao);
                $tot = db_query("select count(*),{$total_campos}\n\t\t\t\t\tfrom ({$query_novo_filtro}) as temp");
            } else {
                $tot = db_query("select count(*) from ({$query_novo_filtro}) as temp");
            }
            //$tot = 0;
            ${$tot_registros} = pg_result($tot, 0, 0);
            if (${$tot_registros} == 0) {
                $Dd2 = "disabled";
            }
        }
    }
    // echo "<script>alert('$NumRows')</script>";
    $NumFields = pg_numfields($result);
    if ($NumRows < $numlinhas && $numlinhas < ${$tot_registros} - ${$offset} - $numlinhas) {
        $Dd1 = @($Dd2 = "disabled");
    }
    echo "<script>\n\t\tfunction js_mostra_text(liga,nomediv,evt){\n\n\t\t\tevt = (evt)?evt:(window.event)?window.event:'';\n\t\t\tif(liga==true){\n\n\t\t\tdocument.getElementById(nomediv).style.top = 0; //evt.clientY;\n\t\t\tdocument.getElementById(nomediv).style.left = 0; //(evt.clientX+20);\n\t\t\tdocument.getElementById(nomediv).style.visibility = 'visible';\n\t\t\t}else\n                    document.getElementById(nomediv).style.visibility = 'hidden';\n\t\t\t}\n\t\t\tfunction js_troca_ordem(nomeform,campo,valor){\n\t\t\tobj=document.createElement('input');\n\t\t\t\tobj.setAttribute('name',campo);\n\t\t\t\tobj.setAttribute('type','submit');\n\t\t\t\tobj.setAttribute('value',valor);\n\t\t\t\tobj.setAttribute('style','color:#FCA;background-color:transparent;border-style:none');\n\t\t\t\t\teval('document.'+nomeform+'.appendChild(obj)');\n\t\t\t\teval('document.'+nomeform+'.'+campo+'.click()');\n\t\t\t}\n\t\t\t\tfunction js_lanca_codigo_pesquisa(valor_recebido){\n\t\t\t\tdocument.navega_lov" . $NomeForm . ".codigo_pesquisa.value = valor_recebido;\n\t\t\t}\n\t\t\tfunction js_lanca_distinct_pesquisa(){\n\t\t\tdocument.navega_lov" . $NomeForm . ".distinct_pesquisa.value = 1;\n\t\t\t}\n\t\t\tfunction js_nova_quantidade_linhas(valor_recebido){\n\t\t\tvalor_recebe = Number(valor_recebido);\n          if(!valor_recebe){\n\t\t\talert('Valor Inválido!');\n\t\t\tdocument.navega_lov" . $NomeForm . ".nova_quantidade_linhas.value = '';\n                document.getElementById('quant_lista').value = '';\n\t\t}else{\n\t\tif(valor_recebe > 100){\n\t\t\tdocument.navega_lov" . $NomeForm . ".nova_quantidade_linhas.value = '100';\n\t\t\tdocument.getElementById('quant_lista').value = 100;\n\t\t}else{\n\t\t\tdocument.navega_lov" . $NomeForm . ".nova_quantidade_linhas.value = valor_recebido;\n\t\t}\n\t\t}\n\t\t}\n\t\t</script>";
    echo "<table id=\"TabDbLov\" border=\"1\" cellspacing=\"1\" cellpadding=\"0\" class=\"lov\">\n";
    /**** botoes de navegacao ********/
    echo "<tr><td colspan=\"" . ($NumFields + 1) . "\" nowrap> <form name=\"navega_lov" . $NomeForm . "\" method=\"post\">\n\t    <input type=\"submit\" name=\"pri" . $NomeForm . "\" value=\"Início\" " . @$Dd1 . " class=\"botao\">\n\t    <input type=\"submit\" name=\"ant" . $NomeForm . "\" value=\"Anterior\" " . @$Dd1 . " class=\"botao\">\n\t    <input type=\"submit\" name=\"prox" . $NomeForm . "\" value=\"Próximo\" " . @$Dd2 . " class=\"botao\">\n\t    <input type=\"submit\" name=\"ult" . $NomeForm . "\" value=\"Último\" " . @$Dd2 . " class=\"botao\">\n\t\t\t<input type=\"hidden\" name=\"offset" . $NomeForm . "\" value=\"" . @${$offset} . "\">\n\t\t\t<input type=\"hidden\" name=\"totreg" . $NomeForm . "\" value=\"" . @${$tot_registros} . "\">\n\t\t\t<input type=\"hidden\" name=\"codigo_pesquisa\" value=\"\">\n\n\t\t\t<input type=\"hidden\" name=\"distinct_pesquisa\" value=\"\">\n\n\t\t\t<input type=\"hidden\" name=\"filtro\" value=\"{$filtro}\">\n";
    reset($variaveis_repassa);
    if (sizeof($variaveis_repassa) > 0) {
        for ($varrep = 0; $varrep < sizeof($variaveis_repassa); $varrep++) {
            echo "<input type=\"hidden\" name=\"" . key($variaveis_repassa) . "\" value=\"" . $variaveis_repassa[key($variaveis_repassa)] . "\">\n";
            next($variaveis_repassa);
        }
    }
    if (isset($ordem_lov) && (isset($ordem_ordenacao) && $ordem_ordenacao == '')) {
        echo "<input type=\"hidden\" name=\"ordem_lov_anterior\" value=\"" . $HTTP_POST_VARS[key($HTTP_POST_VARS)] . "\">\n";
    }
    if (isset($HTTP_POST_VARS['nova_quantidade_linhas']) && $HTTP_POST_VARS['nova_quantidade_linhas'] == '') {
        $numlinhas = $HTTP_POST_VARS['nova_quantidade_linhas'];
    }
    echo "<input type=\"hidden\" name=\"nova_quantidade_linhas\" value=\"{$numlinhas}\" >\n";
    if (isset($totalizacao) && isset($tot)) {
        if (count($totalizacao) > 0) {
            $totNumfields = pg_numfields($tot);
            for ($totrep = 1; $totrep < $totNumfields; $totrep++) {
                echo "<input type=\"hidden\" name=\"totrep_" . pg_fieldname($tot, $totrep) . "\" value=\"" . db_formatar(pg_result($tot, 0, $totrep), 'f') . "\">";
            }
            reset($totalizacao);
            $totrepreg = "";
            $totregsep = "";
            for ($totrep = 0; $totrep < count($totalizacao); $totrep++) {
                $totrepreg .= $totregsep . key($totalizacao) . "=" . $totalizacao[key($totalizacao)];
                $totregsep = "|";
                next($totalizacao);
            }
            reset($totalizacao);
            echo "<input type=\"hidden\" name=\"totalizacao_repas\" value=\"" . $totrepreg . "\">";
        }
    } else {
        if (isset($HTTP_POST_VARS["totalizacao_repas"])) {
            $totalizacao_split = split("\\|", $HTTP_POST_VARS["totalizacao_repas"]);
            for ($totrep = 0; $totrep < count($totalizacao_split); $totrep++) {
                $totalizacao_sep = split("\\=", $totalizacao_split[$totrep]);
                $totalizacao[$totalizacao_sep[0]] = $totalizacao_sep[1];
                if (isset($HTTP_POST_VARS["totrep_" . $totalizacao_sep[0]])) {
                    echo "<input type=\"hidden\" name=\"totrep_" . $totalizacao_sep[0] . "\" value=\"" . $HTTP_POST_VARS["totrep_" . $totalizacao_sep[0]] . "\">";
                }
            }
            echo "<input type=\"hidden\" name=\"totalizacao_repas\" value=\"" . $HTTP_POST_VARS["totalizacao_repas"] . "\">";
        }
    }
    echo "<input type=\"hidden\" name=\"filtroquery\" value=\"" . str_replace("\n", "", @$filtroquery) . "\">\n          " . ($NumRows > 0 ? "\n          Foram retornados <font color=\"red\"><strong>" . ${$tot_registros} . "</strong></font> registros.\n\t\tMostrando de <font color=\"red\"><strong>" . (@${$offset} + 1) . "</strong></font> até\n          <font color=\"red\"><strong>" . (${$tot_registros} < @${$offset} + $numlinhas ? $NumRows <= $numlinhas ? ${$tot_registros} : $NumRows : ${$offset} + $numlinhas) . "</strong></font>." : "Nenhum Registro\n\t\tRetornado") . "</form>\n          </td></tr>\n";
    /*********************************/
    /***** Escreve o cabecalho *******/
    if ($NumRows > 0) {
        echo "<tr>\n";
        // implamentacao de informacoes complementares
        //    echo "<td title='Outras Informações'>OI</td>\n";
        //se foi passado funcao
        if ($campos_layer != "") {
            $campo_layerexe = split("\\|", $campos_layer);
            echo "<td nowrap bgcolor=\"{$db_corcabec}\" title=\"Executa Procedimento Específico.\" align=\"center\">Clique</td>\n";
        }
        $clrotulocab = new rotulolov();
        for ($i = 0; $i < $NumFields; $i++) {
            if (strlen(strstr(pg_fieldname($result, $i), "db_")) == 0) {
                $clrotulocab->label(pg_fieldname($result, $i));
                //echo "<td nowrap bgcolor=\"$db_corcabec\" title=\"".$clrotulocab->title."\" align=\"center\"><b><u>".$clrotulocab->titulo."</u></b></td>\n";
                echo "<td nowrap bgcolor=\"{$db_corcabec}\" title=\"" . $clrotulocab->title . "\" align=\"center\"><input name=\"" . pg_fieldname($result, $i) . "\" value=\"" . ucfirst($clrotulocab->titulo) . "\" type=\"button\" onclick=\"js_troca_ordem('navega_lov" . $NomeForm . "','ordem_dblov" . pg_fieldname($result, $i) . "','" . pg_fieldname($result, $i) . "');\" style=\"text-decoration:underline;background-color:transparent;border-style:none\"> </td>\n";
            } else {
                if (strlen(strstr(pg_fieldname($result, $i), "db_m_")) != 0) {
                    echo "<td nowrap bgcolor=\"{$db_corcabec}\" title=\"" . substr(pg_fieldname($result, $i), 5) . "\" align=\"center\"><b><u>" . substr(pg_fieldname($result, $i), 5) . "</u></b></td>\n";
                }
            }
        }
        echo "</tr>\n";
    }
    //cria nome da funcao com parametros
    if ($arquivo == "()") {
        $arrayFuncao = split("\\|", $aonde);
        $quantidadeItemsArrayFuncao = sizeof($arrayFuncao);
    }
    /********************************/
    /****** escreve o corpo *******/
    for ($i = 0; $i < $NumRows; $i++) {
        echo '<tr >' . "\n";
        // implamentacao de informacoes complementares
        //          echo '<td onMouseOver="document.getElementById(\'div'.$i.'\').style.visibility=\'visible\';" onMouseOut="document.getElementById(\'div'.$i.'\').style.visibility=\'hidden\';" >-></td>'."\n";
        if ($arquivo == "()") {
            $loop = "";
            $caracter = "";
            if ($quantidadeItemsArrayFuncao > 1) {
                for ($cont = 1; $cont < $quantidadeItemsArrayFuncao; $cont++) {
                    if (strlen($arrayFuncao[$cont]) > 3) {
                        for ($luup = 0; $luup < pg_NumFields($result); $luup++) {
                            if (pg_FieldName($result, $luup) == "db_" . $arrayFuncao[$cont]) {
                                $arrayFuncao[$cont] = "db_" . $arrayFuncao[$cont];
                            }
                        }
                    }
                    $loop .= $caracter . "'" . addslashes(str_replace('"', '', @pg_result($result, $i, strlen($arrayFuncao[$cont]) < 4 ? (int) $arrayFuncao[$cont] : $arrayFuncao[$cont]))) . "'";
                    //$loop .= $caracter."'".pg_result($result,$i,(int)$arrayFuncao[$cont])."'";
                    $caracter = ",";
                }
                $resultadoRetorno = $arrayFuncao[0] . "(" . $loop . ")";
            } else {
                $resultadoRetorno = $arrayFuncao[0] . "()";
            }
        }
        /*
        	if($NumRows==1){
        if($arquivo!=""){
        echo "<td>$resultadoRetorno<td>";
        exit;
        }else{
        echo "<script>JanBrowse = window.open('".$arquivo."?".base64_encode("retorno=".($BrowSe==1?0:trim(pg_result($result,0,0))))."','$aonde','width=800,height=600');</script>";
        exit;
        }
        }
        */
        if (isset($cor)) {
            $cor = $cor == $cor1 ? $cor2 : $cor1;
        } else {
            $cor = $cor1;
        }
        // implamentacao de informacoes complementares
        //    $mostradiv="";
        if ($campos_layer != "") {
            $campo_layerexe = split("\\|", $campos_layer);
            echo "<td id=\"funcao_aux" . $i . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a href=\"\" onclick=\"" . $campo_layerexe[1] . "({$loop});return false\" ><strong>" . $campo_layerexe[0] . "&nbsp;</strong></a></td>\n";
        }
        for ($j = 0; $j < $NumFields; $j++) {
            if (strlen(strstr(pg_fieldname($result, $j), "db_")) == 0 || strlen(strstr(pg_fieldname($result, $j), "db_m_")) != 0) {
                if (pg_fieldtype($result, $j) == "date") {
                    if (pg_result($result, $i, $j) != "") {
                        $matriz_data = split("-", pg_result($result, $i, $j));
                        $var_data = $matriz_data[2] . "/" . $matriz_data[1] . "/" . $matriz_data[0];
                    } else {
                        $var_data = "//";
                    }
                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                } else {
                    if (pg_fieldtype($result, $j) == "float8" || pg_fieldtype($result, $j) == "float4") {
                        $var_data = db_formatar(pg_result($result, $i, $j), 'f', ' ');
                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000\" bgcolor=\"{$cor}\" align=right nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                    } else {
                        if (pg_fieldtype($result, $j) == "bool") {
                            $var_data = pg_result($result, $i, $j) == 'f' || pg_result($result, $i, $j) == '' ? 'Não' : 'Sim';
                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;align:right\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                        } else {
                            if (pg_fieldtype($result, $j) == "text") {
                                $var_data = substr(pg_result($result, $i, $j), 0, 10) . "...";
                                echo "<td onMouseOver=\"js_mostra_text(true,'div_text_" . $i . "_" . $j . "',event);\" onMouseOut=\"js_mostra_text(false,'div_text_" . $i . "_" . $j . "',event)\" id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;align:right\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim($var_data) . "</a>" : trim($var_data)) . "&nbsp;</td>\n";
                            } else {
                                if (pg_fieldname($result, $j) == 'j01_matric') {
                                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Imóvel' onclick=\"js_JanelaAutomatica('iptubase','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                } else {
                                    if (pg_fieldname($result, $j) == 'm80_codigo') {
                                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Lançamento' onclick=\"js_JanelaAutomatica('matestoqueini','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                    } else {
                                        if (pg_fieldname($result, $j) == 'm40_codigo') {
                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Requisição' onclick=\"js_JanelaAutomatica('matrequi','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                        } else {
                                            if (pg_fieldname($result, $j) == 'm42_codigo') {
                                                echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Atendimento' onclick=\"js_JanelaAutomatica('atendrequi','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                            } else {
                                                if (pg_fieldname($result, $j) == 'm45_codigo') {
                                                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Devolução' onclick=\"js_JanelaAutomatica('matestoquedev','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                } else {
                                                    if (pg_fieldname($result, $j) == 't52_bem') {
                                                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Bem' onclick=\"js_JanelaAutomatica('bem','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                    } else {
                                                        if (pg_fieldname($result, $j) == 'q02_inscr') {
                                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Issqn' onclick=\"js_JanelaAutomatica('issbase','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                        } else {
                                                            if (pg_fieldname($result, $j) == 'z01_numcgm') {
                                                                echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações Contribuinte/Empresa' onclick=\"js_JanelaAutomatica('cgm','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                            } else {
                                                                if (pg_fieldname($result, $j) == 'e60_numemp' || pg_fieldname($result, $j) == 'e61_numemp' || pg_fieldname($result, $j) == 'e62_numemp') {
                                                                    echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações do Empenho' onclick=\"js_JanelaAutomatica('empempenho','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                } else {
                                                                    if (pg_fieldname($result, $j) == 'e54_autori' || pg_fieldname($result, $j) == 'e55_autori' || pg_fieldname($result, $j) == 'e56_autori') {
                                                                        echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações da Autorização de Empenho' onclick=\"js_JanelaAutomatica('empautoriza','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                    } else {
                                                                        if (pg_fieldname($result, $j) == "pc10_numero") {
                                                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap><a title='Informações da Solicitação' onclick=\"js_JanelaAutomatica('empsolicita','" . trim(pg_result($result, $i, $j)) . "');return false;\">&nbsp;Inf->&nbsp;</a>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                        } else {
                                                                            echo "<td id=\"I" . $i . $j . "\" style=\"text-decoration:none;color:#000000;\" bgcolor=\"{$cor}\" nowrap>" . ($arquivo != "" ? "<a title=\"{$mensagem}\" style=\"text-decoration:none;color:#000000;\" href=\"\" " . ($arquivo == "()" ? "OnClick=\"" . $resultadoRetorno . ";return false\">" : "onclick=\"JanBrowse = window.open('" . $arquivo . "?" . base64_encode("retorno=" . ($BrowSe == 1 ? $i : trim(pg_result($result, $i, 0)))) . "','{$aonde}','width=800,height=600');return false\">") . trim(pg_result($result, $i, $j)) . "</a>" : trim(pg_result($result, $i, $j))) . "&nbsp;</td>\n";
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        echo "</tr>\n";
        // implamentacao de informacoes complementares
        //    $divmostra .= "</table>";
        //    $divmostra .= '<div id="div'.$i.'" name="div'.$i.'" style="position:absolute; left:30px; top:40px; z-index:1; visibility: hidden; border: 1px none #000000; background-color: #CCCCCC; layer-background-color: #CCCCCC;">';
        //    $divmostra .= '<table  border=\"1\"  align=\"center\" cellspacing=\"1\">';
        //    $divmostra .= '<tr>';
        //    $divmostra .= '<td> '.$mostradiv;
        //    $divmostra .= '</td> ';
        //    $divmostra .= '</tr> ';
        //    $divmostra .= '</table>';
        //    $divmostra .= '</div>';
    }
    //  echo $divmostra;
    /******************************/
    if (count($totalizacao) > 0) {
        echo "<tr>";
        for ($j = 0; $j < $NumFields; $j++) {
            $key_elemento = array_search(pg_fieldname($result, $j), $totalizacao);
            if ($key_elemento == true && pg_fieldname($result, $j) == $key_elemento && strlen(strstr(pg_fieldname($result, $j), "db_")) == 0) {
                @($vertotrep = $HTTP_POST_VARS['totrep_' . $key_elemento]);
                if (@$vertotrep != "" && !isset($tot)) {
                    echo "<td style=\"text-decoration:none;color:#000000\" bgcolor=\"white\" align=right nowrap> " . $vertotrep . "&nbsp;</td>\n";
                } else {
                    if (isset($tot)) {
                        echo "<td style=\"text-decoration:none;color:#000000\" bgcolor=\"white\" align=right nowrap> " . db_formatar(pg_result($tot, 0, $key_elemento), 'f') . "&nbsp;</td>\n";
                    } else {
                        echo "<td style=\"text-decoration:none;color:#000000\" bgcolor=\"white\" align=right nowrap> &nbsp;</td>\n";
                    }
                }
            } else {
                if ($key_elemento == 'totalgeral') {
                    echo "<td align='right'><strong>Total Geral : </strong></td>";
                } else {
                    if (strlen(strstr(pg_fieldname($result, $j), "db_")) == 0) {
                        echo "<td></td>";
                    }
                }
            }
        }
        echo "</tr>";
    }
    if ($NumRows > 0) {
        echo "<tr><td colspan={$NumFields} >\n              <input name='recomecar' type='button' value='Recomeçar' onclick=\"js_troca_ordem('navega_lov" . $NomeForm . "','recomecar','0');\" class=\"botao\">\n\t\t\t\t\t\t<strong>Indique o Conteúdo:</strong><input title='Digite o valor a pesquisar e clique sobre o campo (cabeçalho) a pesquisar' name=indica_codigo type=text onchange='js_lanca_codigo_pesquisa(this.value)' style='background-color:#E6E4F1'>\n\t\t\t\t\t\t<strong>Quantidade a Listar:</strong><input id=quant_lista name=quant_lista type=text onchange='js_nova_quantidade_linhas(this.value)' style='background-color:#E6E4F1' value='{$numlinhas}' size='5'>\n\t\t\t\t\t\t<strong>Mostra Diferentes:</strong><input title='Mostra os valores diferentes clicando no cabeçalho a pesquisar' name=mostra_diferentes type=checkbox onchange='js_lanca_distinct_pesquisa()' style='background-color:#E6E4F1'>\n\t\t\t\t\t\t</td>";
        echo "</tr>\n";
    }
    echo "</table>";
    for ($i = 0; $i < $NumRows; $i++) {
        for ($j = 0; $j < $NumFields; $j++) {
            if (pg_fieldtype($result, $j) == "text") {
                $clrotulocab->label(pg_fieldname($result, $j));
                echo "<div id='div_text_" . $i . "_" . $j . "' style='position:absolute;left:10px; top:10px; visibility:hidden ; background-color:#6699CC ; border:2px outset #cccccc; align:left'>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left'>\n\t\t\t\t\t\t<font color='black' face='arial' size='2'><strong>" . $clrotulocab->titulo . "</strong>:</font><br>\n\t\t\t\t\t\t<font color='black' face='arial' size='1'>" . str_replace("\n", "<br>", pg_result($result, $i, $j)) . "</font>\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t</div>";
            }
        }
    }
    if ($automatico == true) {
        if (pg_numrows($result) == 1 && ${$offset} == 0) {
            echo "<script>" . @$resultadoRetorno . "</script>";
        }
    }
    return $result;
}
Example #11
0
 function FieldType($result, $offset)
 {
     switch ($this->dbType) {
         case "mssql":
             $r = mssql_field_type($result, $offset);
             break;
         case "mysql":
             $r = mysql_field_type($result, $offset);
             break;
         case "pg":
             $r = pg_fieldtype($result, $offset);
             break;
         default:
             $r = False;
             break;
     }
     return $r;
 }
Example #12
0
        ?>
</th>
		<th><?php 
        echo $strType;
        ?>
</th>
		<th><?php 
        echo $strValue;
        ?>
</th>
		</tr>
		<?php 
        $result = pg_exec($link, pre_query($sql_get_fields));
        for ($i = 0; $i < pg_numfields($result); $i++) {
            $field = pg_fieldname($result, $i);
            $type = pg_fieldtype($result, $i);
            $len = pg_fieldsize($result, $i);
            if ($len < 1) {
                $len_disp = "var";
                $len = 50;
            } else {
                $len_disp = $len;
            }
            $bgcolor = $cfgBgcolorOne;
            $i % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
            echo "<tr bgcolor=" . $bgcolor . ">";
            echo "<td>{$field}</td>";
            echo "<td>{$type} ({$len_disp})</td>";
            if ($type == "bool") {
                echo "<td><select name=fields[]><option value=\"t\">True<option value=\"f\">False</select></td>";
            } else {
        }
        updatesquirrel();
    }
    print "CREATE TABLE {$tbl_name} (" . implode(",", $create_fields) . ") WITH OIDS;\n";
    foreach ($sequences as $seq_name => $nextval) {
        print "SELECT setval('{$seq_name}',{$nextval});\n";
    }
    status("done creating query data.\n\n");
    // create the insert data queries
    status("dumping data for table... ");
    //print "BEGIN;\n";
    while ($fld_row = pg_fetch_row($flds_rslt)) {
        $idata = "";
        foreach ($fld_row as $key => $value) {
            // read the field information
            $f_type = pg_fieldtype($flds_rslt, $key);
            // if the type is numeric or float and empty set it to zero
            if (empty($value) && preg_match("/^(float|numeric|int)/", $f_type)) {
                $value = "0";
            }
            // escape the quotes
            $value = str_replace("'", "\\'", $value);
            $idata[] = "'{$value}'";
            updatesquirrel();
        }
        $query_indata = implode(",", $idata);
        print "INSERT INTO {$tbl_name} (" . implode(",", $insert_fields) . ") VALUES({$query_indata});\n";
    }
    //print "COMMIT;\n";
    status("done\n");
}
Example #14
0
 /**
  * Returns information about a table or a result set.
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * @param object|string  $result  MDB2_result object from a query or a
  *                                string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  * @return array  an associative array with the information requested
  *                or an error object if something is wrong
  * @access public
  * @internal
  * @see MDB2_Driver_Common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     $db =& $GLOBALS['_MDB2_databases'][$this->db_index];
     if ($db->options['portability'] & MDB2_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     if (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         if (MDB2::isError($connect = $db->connect())) {
             return $connect;
         }
         $id = @pg_exec($db->connection, "SELECT * FROM {$result} LIMIT 0");
         $got_string = true;
     } else {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->getResource();
         if (empty($id)) {
             return $db->raiseError();
         }
         $got_string = false;
     }
     if (!is_resource($id)) {
         return $db->raiseError(MDB2_ERROR_NEED_MORE_DATA);
     }
     $count = @pg_numfields($id);
     // made this IF due to performance (one if is faster than $count if's)
     if (!$mode) {
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $got_string ? $case_func($result) : '';
             $res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = $got_string ? $this->_pgFieldflags($id, $i, $result) : '';
         }
     } else {
         // full
         $res['num_fields'] = $count;
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $got_string ? $case_func($result) : '';
             $res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = $got_string ? $this->_pgFieldFlags($id, $i, $result) : '';
             if ($mode & MDB2_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & MDB2_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
     }
     // free the result only if we were called on a table
     if ($got_string) {
         @pg_freeresult($id);
     }
     return $res;
 }
function tipocampo_query($query, $num)
{
    $risul = pg_fieldtype($query, $num);
    return $risul;
}
 function &FetchField($fieldOffset = 0)
 {
     $off = $fieldOffset;
     // offsets begin at 0
     $o = new ADOFieldObject();
     $o->name = @pg_fieldname($this->_queryID, $off);
     $o->type = @pg_fieldtype($this->_queryID, $off);
     $o->max_length = @pg_fieldsize($this->_queryID, $off);
     //print_r($o);
     //print "off=$off name=$o->name type=$o->type len=$o->max_length<br>";
     return $o;
 }
Example #17
0
 function get_table_content($link, $table, $handler)
 {
     global $cfgQuotes;
     $result = @pg_exec($link, "SELECT * FROM {$cfgQuotes}{$table}{$cfgQuotes}") or pg_die(pg_errormessage(), "", __FILE__, __LINE__);
     $iNumFields = pg_numfields($result);
     // Gather info about each column in the table
     for ($iField = 0; $iField < $iNumFields; $iField++) {
         $aryType[] = pg_fieldtype($result, $iField);
         $aryName[] = pg_fieldname($result, $iField);
     }
     $iRec = 0;
     while ($row = @pg_fetch_array($result, $iRec++)) {
         unset($schema_vals);
         unset($schema_fields);
         unset($schema_insert);
         for ($iFieldVal = 0; $iFieldVal < $iNumFields; $iFieldVal++) {
             $strVal = $row[$aryName[$iFieldVal]];
             if (eregi("char|text", $aryType[$iFieldVal])) {
                 $strQuote = "'";
                 $strEmpty = "";
                 $strVal = addslashes($strVal);
             } elseif (eregi("date|time|inet|bool", $aryType[$iFieldVal])) {
                 if (empty($strVal)) {
                     $strQuote = "";
                 } else {
                     $strQuote = "'";
                 }
                 $strEmpty = "NULL";
             } else {
                 $strQuote = "";
                 $strEmpty = "NULL";
             }
             if (empty($strVal) && $strVal != "0") {
                 $strVal = $strEmpty;
             }
             $schema_vals .= " {$strQuote}{$strVal}{$strQuote},";
             $schema_fields .= " {$cfgQuotes}{$aryName[$iFieldVal]}{$cfgQuotes},";
         }
         $schema_vals = ereg_replace(",\$", "", $schema_vals);
         $schema_vals = ereg_replace("^ ", "", $schema_vals);
         $schema_fields = ereg_replace(",\$", "", $schema_fields);
         $schema_fields = ereg_replace("^ ", "", $schema_fields);
         $schema_insert = "INSERT INTO {$cfgQuotes}{$table}{$cfgQuotes} ({$schema_fields}) VALUES({$schema_vals})";
         $handler(trim($schema_insert));
     }
     return true;
 }
 function &FetchField($off = 0)
 {
     // offsets begin at 0
     $o = new ADOFieldObject();
     $o->name = @pg_fieldname($this->_queryID, $off);
     $o->type = @pg_fieldtype($this->_queryID, $off);
     $o->max_length = @pg_fieldsize($this->_queryID, $off);
     return $o;
 }
Example #19
0
 function sql_fieldtype($offset, $query_id = 0)
 {
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $starttime = $mtime;
     if (!$query_id) {
         $query_id = $this->query_result;
     }
     $mtime = microtime();
     $mtime = explode(" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $endtime = $mtime;
     $this->sql_time += $endtime - $starttime;
     return $query_id ? @pg_fieldtype($query_id, $offset) : false;
 }