Esempio n. 1
0
function db_query($query, $limit = false, $suppress_error = false, $offset = false)
{
    global $_josh;
    db_open();
    $query = trim($query);
    if (isset($_josh["basedblanguage"]) && $_josh["basedblanguage"] != $_josh["db"]["language"]) {
        $query = db_translate($query, $_josh["basedblanguage"], $_josh["db"]["language"]);
    }
    $_josh["queries"][] = $query;
    if ($_josh["db"]["language"] == "mysql") {
        if ($limit) {
            $query .= " LIMIT " . $limit;
        }
        if ($offset) {
            $query .= " OFFSET " . $offset;
        }
        if ($result = @mysql_query($query, $_josh["db"]["pointer"])) {
            error_debug("<b>db_query</b> <i>" . $query . "</i>, " . db_found($result) . " results returned");
            if (format_text_starts("insert", $query)) {
                return db_id();
            }
            return $result;
        } else {
            error_debug("<b>db_query</b> failed <i>" . $query . "</i>");
            if ($suppress_error) {
                return false;
            }
            error_handle("mysql error", format_code($query) . "<br>" . mysql_error());
        }
    } elseif ($_josh["db"]["language"] == "mssql") {
        //echo $_josh["db"]["location"]. " db";
        if ($limit) {
            $query = "SELECT TOP " . $limit . substr($query, 6);
        }
        if ($result = @mssql_query($query, $_josh["db"]["pointer"])) {
            error_debug("<b>db_query</b> <i>" . $query . "</i>, " . db_found($result) . " results returned");
            if (format_text_starts("insert", $query)) {
                return db_id();
            }
            return $result;
        } else {
            if ($suppress_error) {
                return false;
            }
            error_handle("mssql error", format_code($query) . "<br>" . mssql_get_last_message());
        }
    }
}
 /*=============================================================================================*/
 /**
  * Informações de Cabeçalho
  */
 $pdf1->prefeitura = $prefeitura;
 $pdf1->enderpref = $enderpref;
 $pdf1->municpref = $municpref;
 $pdf1->telefpref = $telefpref;
 $pdf1->cgcpref = $cgcpref;
 /**
  * Informações Contribuintes
  */
 $pdf1->cpf = $oRendimento->rh96_cpfcnpj;
 $pdf1->nome = db_translate($oRendimento->z01_nome);
 $pdf1->resp = db_translate($resp);
 $pdf1->pensionistas = db_translate($nome_pens);
 $pdf1->ano = $anobase;
 $pdf1->matricula = str_replace('}', '', str_replace('{', '', $oRendimento->regist));
 $pdf1->lotacao = $oRendimento->r70_codigo;
 $pdf1->num_comprovante = $iInd + 1;
 /**
  * Informações Bloco Rendimentos Isentos e Não Tributáveis
  */
 $oRendimento->rendimento -= $oRendimento->aposentadoria_65 + $oRendimento->molestia_grave_inativos + $oRendimento->molestia_grave_ativos;
 $pdf1->w_salario = $oRendimento->rendimento < 0 ? 0 : $oRendimento->rendimento;
 $pdf1->w_contr = $oRendimento->prev_oficial;
 $pdf1->w_privad = $oRendimento->prev_privada;
 $pdf1->w_pensao = $oRendimento->pensao + $oRendimento->pensao_13;
 $pdf1->w_irfonte = $oRendimento->irrf;
 $pdf1->w_parte = $oRendimento->aposentadoria_65 + $oRendimento->aposentadoria_65_13;
 $pdf1->w_diaria = $oRendimento->diaria;