function pgquery($query)
 {
     $result = pg_exec($this->pgcon(), $query);
     if (!$result) {
         $this->mydie("Could not successfully run query ({$query}) from DB: " . pg_ErrorMessage());
     }
     return $result;
 }
Beispiel #2
0
 function pg_db_send_query($iConn, $sQry)
 {
     $iQuery = @pg_send_query($iConn, $sQry);
     if (!$iQuery) {
         $erro = pg_ErrorMessage($iConn) . "\n" . $sQry;
         msgErro($erro);
     }
     return $iQuery;
 }
Beispiel #3
0
function exec_query($connection, $query)
{
    $result = pg_Exec($connection, $query);
    if (!$result) {
        echo "Connection to database failed.";
        echo pg_ErrorMessage($connection);
        return 0;
    }
    return $result;
}
Beispiel #4
0
 function StandaloneQuery(&$db, $query)
 {
     if (($connection = $db->DoConnect("template1", 0)) == 0) {
         return 0;
     }
     if (!($success = @pg_Exec($connection, "{$query}"))) {
         $db->SetError("Standalone query", pg_ErrorMessage($connection));
     }
     pg_Close($connection);
     return $success;
 }
Beispiel #5
0
 function connect()
 {
     if ($this->isConnected()) {
         $this->setError("sqLink->connect(0): Already connected.");
         return false;
     }
     if ($this->db_host) {
         $this->db_host = "host = " . $this->db_host;
     }
     $this->db_link = pg_connect($this->db_host . ' dbname = ' . $this->db_name . ' user = '******' password = ' . $this->db_pass);
     if ($this->db_link) {
         return true;
     } else {
         pg_close($this->db_link);
         $this->setError("Error: sqLink->connect(2) PSQL - " . pg_ErrorMessage($this->db_link));
         return false;
     }
 }
Beispiel #6
0
 function connect()
 {
     if ($this->isConnected()) {
         user_error('sqLink->connect(0): Already connected.');
         return false;
     }
     if ($this->db_host) {
         $this->db_host = "host = " . $this->db_host;
     }
     $this->db_link = pg_connect($this->db_host . " dbname = " . $this->db_name . " user = "******" password = "******"Error: sqLink->connect(2)PSQL - " . pg_ErrorMessage($this->db_link));
         return false;
     }
 }
 function metadata($table = "")
 {
     $count = 0;
     $id = 0;
     $res = array();
     if ($table) {
         $this->connect();
         $id = pg_exec($this->Link_ID, "SELECT * FROM {$table}");
         if ($id < 0) {
             $this->Error = pg_ErrorMessage($id);
             $this->Errno = 1;
             $this->halt("Metadata query failed.");
         }
     } else {
         $id = $this->Query_ID;
         if (!$id) {
             $this->halt("No query specified.");
         }
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res[$i]["table"] = $table;
         $res[$i]["name"] = pg_FieldName($id, $i);
         $res[$i]["type"] = pg_FieldType($id, $i);
         $res[$i]["len"] = pg_FieldSize($id, $i);
         $res[$i]["flags"] = "";
     }
     if ($table) {
         pg_FreeResult($id);
     }
     return $res;
 }
Beispiel #8
0
if (!file_exists($filename) || filemtime($filename) + $period < time()) {
    // get graph information
    global $db;
    // XXX CHANGE THE QUERY XXX
    $data = @pg_exec($db, "select query, title, label, is_clickable from graphs where id = {$id}") or die("PGERR 1: " . pg_ErrorMessage());
    if (pg_numrows($data) == 0) {
        die("GRAPH: invalid id");
    }
    $r = pg_fetch_row($data, $i);
    $query = $r[0];
    $title = $r[1];
    $axislabel = $r[2];
    $is_clickable = $r[3];
    pg_freeresult($data);
    // get graph data
    $data = @pg_exec($db, $query) or die("PGERR 2: " . pg_ErrorMessage());
    $v = array();
    $l = array();
    $u = array();
    for ($i = 0; $i < pg_numrows($data); $i++) {
        $r = pg_fetch_row($data, $i);
        array_push($v, $r[1]);
        array_push($l, $r[0] . "  ");
        array_push($u, $r[2]);
    }
    pg_freeresult($data);
    // draw
    $map = FreshPortsChart($title, $axislabel, $v, $l, $u, $filename);
    if ($is_clickable == 't') {
        // save map
        $fp = fopen($cache_dir . $fid . ".map", "w");
Beispiel #9
0
 function metadata($table)
 {
     $count = 0;
     $id = 0;
     $res = array();
     $this->connect();
     $id = pg_exec($this->Link_ID, "select * from {$table} LIMIT 1");
     if ($id < 0) {
         $this->Error = pg_ErrorMessage($id);
         $this->Errno = 1;
         $this->Errors->addError("Metadata query failed: " . $this->Error);
         return 0;
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res[$i]["table"] = $table;
         $res[$i]["name"] = pg_FieldName($id, $i);
         $res[$i]["type"] = pg_FieldType($id, $i);
         $res[$i]["len"] = pg_FieldSize($id, $i);
         $res[$i]["flags"] = "";
     }
     pg_FreeResult($id);
     return $res;
 }
/**
 * reports ands logs error
 *
 * skip the log of there are filesystem problems.
 *
 * @param string $err
 * @param bool $skiplog
 */
function errDie($errstring, $skiplog = false)
{
    $err = DATE_LOGGING . " - " . SELF . " - {$errstring}";
    if (pg_ErrorMessage()) {
        $err .= " - " . pg_ErrorMessage();
    }
    // log error to file
    die($errstring);
    if ($skiplog === false && ($fd = cfs::fopen("error_log", 'a'))) {
        if (cfs::fwrite($fd, "{$err}\n")) {
            $errlog_msg = "Error has been logged. Please notify the administrator.";
        } else {
            $errlog_msg = "Error writing to error log. Please notify the administrator.";
        }
        cfs::fclose($fd);
    } else {
        $errlog_msg = "Error opening error log. Please notify the administrator.";
    }
    $OUTPUT = "{$errstring} {$errlog_msg}";
    require "newtemplate.php";
}
Beispiel #11
0
 /**
  * Convert a text value into a DBMS specific format that is suitable to
  * compose query statements.
  *
  * @param resource  $prepared_query query handle from prepare()
  * @param           $parameter
  * @param           $lob
  * @return string text string that represents the given argument value in
  *      a DBMS specific format.
  * @access private
  */
 function _getLobValue($prepared_query, $parameter, $lob)
 {
     $connect = $this->connect();
     if (MDB::isError($connect)) {
         return $connect;
     }
     if ($this->auto_commit && !@pg_exec($this->connection, 'BEGIN')) {
         return $this->raiseError(MDB_ERROR, NULL, NULL, '_getLobValue: error starting transaction');
     }
     if ($lo = @pg_locreate($this->connection)) {
         if ($handle = @pg_loopen($this->connection, $lo, 'w')) {
             while (!$this->endOfLob($lob)) {
                 $result = $this->readLob($lob, $data, $this->options['lob_buffer_length']);
                 if (MDB::isError($result)) {
                     break;
                 }
                 if (!@pg_lowrite($handle, $data)) {
                     $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value: ' . @pg_errormessage($this->connection));
                     break;
                 }
             }
             @pg_loclose($handle);
             if (!MDB::isError($result)) {
                 $value = strval($lo);
             }
         } else {
             $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value: ' . @pg_errormessage($this->connection));
         }
         if (MDB::isError($result)) {
             $result = @pg_lounlink($this->connection, $lo);
         }
     } else {
         $result = $this->raiseError(MDB_ERROR, NULL, NULL, 'Get LOB field value: ' . pg_ErrorMessage($this->connection));
     }
     if ($this->auto_commit) {
         @pg_exec($this->connection, 'END');
     }
     if (MDB::isError($result)) {
         return $result;
     }
     return $value;
 }
Beispiel #12
0
 function _generate_csv($query_string, $dbname = "mysql", $user = "******", $password = "", $host = "localhost")
 {
     /*echo " dbname=cdrasterisk host=db01.fr4.egwn.net user=ivr password=7Q8GFTK9fq </br>$query_string<br>";
       $ConnId = pg_connect("dbname=cdrasterisk host=db01.fr4.egwn.net user=ivr password=7Q8GFTK9fq");
       $ResId = pg_query ($ConnId, $query_string);
       if (!$ResId) pg_ErrorMessage($ResId);
       pg_close ($ConnId);
       $row = pg_fetch_array ($ResId, 4);
       print_r($row);
       exit();*/
     if (!($conn = $this->_db_connect($dbname, $user, $password, $host))) {
         die("Error. Cannot connect to Database.");
     } else {
         //$result = @mysql_query($query_string, $conn);
         $result = pg_query($conn, $query_string);
         if (!$result) {
             die("Could not perform the Query: " . pg_ErrorMessage($result));
             //die("Could not perform the Query: ".mysql_error());
         } else {
             $file = "";
             $crlf = $this->_define_newline();
             //while ($str= @mysql_fetch_array($result, MYSQL_NUM))
             while ($str = @pg_fetch_array($result, NULL, PGSQL_NUM)) {
                 $file .= $this->arrayToCsvString($str, ",") . $crlf;
             }
             echo $file;
         }
     }
 }
 function halt($msg, $line = '', $file = '')
 {
     /* private: error handling */
     if ($this->Halt_On_Error == 'no') {
         $this->Error = @pg_ErrorMessage($this->Link_ID);
         $this->Errno = 1;
         return;
     }
     /* Just in case there is a table currently locked */
     $this->transaction_abort();
     if ($this->xmlrpc || $this->soap) {
         $s = sprintf("Database error: %s\n", $msg);
         $s .= sprintf("PostgreSQL Error: %s\n\n (%s)\n\n", $this->Errno, $this->Error);
     } else {
         $s = sprintf("<b>Database error:</b> %s<br>\n", $msg);
         $s .= sprintf("<b>PostgreSQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error);
     }
     if ($file) {
         if ($this->xmlrpc || $this->soap) {
             $s .= sprintf("File: %s\n", $file);
         } else {
             $s .= sprintf("<br><b>File:</b> %s", $file);
         }
     }
     if ($line) {
         if ($this->xmlrpc || $this->soap) {
             $s .= sprintf("Line: %s\n", $line);
         } else {
             $s .= sprintf("<br><b>Line:</b> %s", $line);
         }
     }
     if ($this->Halt_On_Error == 'yes') {
         if (!$this->xmlrpc && !$this->soap) {
             $s .= '<p><b>Session halted.</b>';
         }
     }
     if ($this->xmlrpc) {
         xmlrpcfault($s);
     } elseif ($this->soap) {
     } else {
         echo $s;
         //$GLOBALS['phpgw']->common->phpgw_exit(True);
     }
 }
function errDie($usrString)
{
    $ERROR = DATE_LOGGING . " - " . SELF . " - " . USER_NAME . " - " . $usrString;
    // Create error from scriptname & user string
    if (pg_ErrorMessage()) {
        $ERROR .= " - " . pg_ErrorMessage();
    }
    // log error to file
    $ERROR_LOG = fopen("error_log", 'a') or die("ERROR while opening error_log. Please notify the administrator.");
    flock($ERROR_LOG, LOCK_EX) or die("ERROR obtaining file lock on error_log. Please notify the administrator.");
    fwrite($ERROR_LOG, $ERROR . "\n") or die("ERROR writing to error_log. Please notify the administrator.");
    flock($ERROR_LOG, LOCK_UN);
    fclose($ERROR_LOG);
    $OUTPUT = $usrString . " Error has been logged, please notify the administrator.";
    require "template.php";
}
Beispiel #15
0
<?php

$link = pg_connect("host=localhost port=5432 password=ICInf-551 user=icinf5 dbname=icinf5");
if (!$link) {
    die(' Error al conectarse ' . pg_ErrorMessage($link));
}
    }
    if ($db_verifica_ip == "0") {
        if ($cgccpf == "") {
            db_redireciona('digitaitbi.php?' . base64_encode('erroscripts=Informe o CNPJ/CPF do contribuinte.'));
            exit;
        }
    }
    if (!isset($matricula) or empty($matricula) or !is_int(0 + $matricula)) {
        db_logs("", "", 0, "Variavel Matricula Invalida.");
        db_redireciona("digitatbi.php?" . base64_encode("erroscripts=Os dados informados não conferem, verifique!"));
    }
    $cgccpf = str_replace(".", "", $cgccpf);
    $cgccpf = str_replace("/", "", $cgccpf);
    $cgccpf = str_replace("-", "", $cgccpf);
    $sql_exe = "select ident from db_config";
    $result = pg_exec($sql_exe) or die("Erro: " . pg_ErrorMessage($conn));
    db_fieldsmemory($result, 0);
    /*
      $sql_exe = "select * from iptubase,cgm
                         where j01_matric = $matricula and 
                                   j01_numcgm = z01_numcgm ";
        if ( $db_verifica_ip == "0" ) {
          $sql_exe = $sql_exe . " and trim(z01_cgccpf) = '$cgccpf' and trim(z01_cgccpf) != ''";
        }
      $result = pg_exec($sql_exe) or die("Erro: ".pg_ErrorMessage($conn));
    */
    $result = $cliptubase->sql_record($cliptubase->sql_query("", "*", "", "iptubase.j01_matric = {$matricula} and j01_numcgm = z01_numcgm"));
} else {
    /*
    $result = pg_exec("select * from iptubase,cgm
                         where j01_matric = $matricula and 
Beispiel #17
0
 function query($query)
 {
     if ($this->db_type == "mysql") {
         $this->results = mysql_query($query, $this->conn);
         $this->numFields = mysql_num_fields($this->results);
     } else {
         $this->results = pg_query($this->conn, $query);
         if (!$this->results) {
             die("Could not perform the Query: " . pg_ErrorMessage($this->results));
         }
         $this->numFields = pg_num_fields($this->results);
     }
 }
Beispiel #18
0
 function Setup()
 {
     if (!function_exists("pg_connect")) {
         return "PostgreSQL support is not available in this PHP configuration";
     }
     $this->supported["Sequences"] = $this->supported["Indexes"] = $this->supported["SummaryFunctions"] = $this->supported["OrderByText"] = $this->supported["Transactions"] = $this->supported["GetSequenceCurrentValue"] = $this->supported["SelectRowRanges"] = $this->supported["LOBs"] = $this->supported["Replace"] = $this->supported["AutoIncrement"] = $this->supported["PrimaryKey"] = $this->supported["OmitInsertKey"] = $this->supported["OmitInsertKey"] = $this->supported["PatternBuild"] = 1;
     if (function_exists("pg_cmdTuples")) {
         if ($connection = $this->DoConnect("template1", 0)) {
             if ($result = @pg_Exec($connection, "BEGIN")) {
                 $error_reporting = error_reporting(63);
                 @pg_cmdTuples($result);
                 if (!isset($php_errormsg) || strcmp($php_errormsg, "This compilation does not support pg_cmdtuples()")) {
                     $this->supported["AffectedRows"] = 1;
                 }
                 error_reporting($error_reporting);
             } else {
                 $this->SetError("Setup", pg_ErrorMessage($connection));
             }
             pg_Close($connection);
         } else {
             $result = 0;
         }
         if (!$result) {
             return $this->Error();
         }
     }
     if (isset($this->options["EmulateDecimal"]) && $this->options["EmulateDecimal"]) {
         $this->emulate_decimal = 1;
         $this->decimal_factor = pow(10.0, $this->decimal_places);
     }
     return "";
 }
function debitos_inscricao_var($inscricao, $limite, $tipo, $datausu, $anousu)
{
    $sql = "select *,\n                 substr(fc_calcula,2,13)::float8 as vlrhis,\n                 substr(fc_calcula,15,13)::float8 as vlrcor,\n                 substr(fc_calcula,28,13)::float8 as vlrjuros,\n                 substr(fc_calcula,41,13)::float8 as vlrmulta,\n                 substr(fc_calcula,54,13)::float8 as vlrdesconto,\n                 (substr(fc_calcula,15,13)::float8+\n                 substr(fc_calcula,28,13)::float8+\n                 substr(fc_calcula,41,13)::float8-\n                 substr(fc_calcula,54,13)::float8) as total\n          from (  \n          select q05_aliq,''::bpchar as k00_matric,v.q05_vlrinf as valor_variavel,a.k00_inscr,i.*,histcalc.*,tabrec.k02_descr,fc_calcula(i.k00_numpre,i.k00_numpar,i.k00_receit,'" . date('Y-m-d', $datausu) . "','" . db_vencimento($datausu) . "'," . $anousu . ") \n          from arreinscr a\n                             inner join arrecad i on a.k00_numpre = i.k00_numpre \n                                 left outer join issvar v on v.q05_numpre = i.k00_numpre and v.q05_numpar = i.k00_numpar\n                                 ,histcalc,tabrec  inner join tabrecjm on tabrecjm.k02_codjm = tabrec.k02_codjm\n          where k00_hist   = k01_codigo and \n                        a.k00_inscr = {$inscricao} and\n                                k00_receit = k02_codigo ";
    if ($tipo != 0) {
        $sql .= " and k00_tipo   = " . $tipo;
    }
    $sql .= " order by k00_numpre,k00_numpar,k00_dtvenc";
    if ($limite != 0) {
        $sql .= " limit " . $limite;
    }
    $sql .= ") as x";
    $result = pg_query($sql) or die("Sql : " . pg_ErrorMessage($result));
    if ($limite == 0) {
        if (pg_numrows($result) == 0) {
            false;
        }
        return $result;
    } else {
        if (pg_numrows($result) == 0) {
            return false;
        } else {
            return 1;
        }
    }
}
     $sql_exe = " select *                         ";
     $sql_exe .= "   from issbase,                  ";
     $sql_exe .= "        cgm                       ";
     $sql_exe .= "  where q02_inscr  = {$inscricao}   ";
     $sql_exe .= "    and q02_numcgm = z01_numcgm   ";
     if ($db_verifica_ip == "0") {
         $sql_exe = $sql_exe . " and trim(z01_cgccpf) = '{$cgccpf}'";
     }
     $result = db_query($sql_exe) or die("Erro: " . pg_ErrorMessage($conn));
 } else {
     if (isset($inscricao) != "") {
         $sql = " select * from issbase,                 ";
         $sql .= "               cgm                      ";
         $sql .= "   where q02_inscr = {$inscricao} and   ";
         $sql .= "\t      q02_numcgm = z01_numcgm        ";
         $result = db_query($sql) or die("Erro: " . pg_ErrorMessage($conn));
     }
     $cgccpf = trim(pg_result($result, 0, 'z01_cgccpf'));
 }
 if (pg_numrows($result) == 0) {
     $sUrl = base64_encode("id_usuario=''&erroscripts=Dados Inconsistentes na Inscrição Número: " . $inscricao . ".");
     db_logs("", "{$inscricao}", 0, "Dados Inconsistentes na Inscricao Numero: {$inscricao}");
     db_redireciona("digitainscricao.php?" . $sUrl);
     $script = false;
 } else {
     if (pg_result($result, 0, "z01_cgccpf") == "00000000000000" || pg_result($result, 0, "z01_cgccpf") == "              " || trim(pg_result($result, 0, "z01_cgccpf")) != "{$cgccpf}") {
         $script = true;
     }
     if (pg_numrows($result) > 0) {
         db_fieldsmemory($result, 0);
         db_logs("", "{$inscricao}", 0, "Inscricao Pesquisada. Numero: {$inscricao}");
/**
 * reports ands logs error
 *
 * skip the log of there are filesystem problems.
 *
 * @param string $err
 * @param bool $skiplog
 */
function errDie($errstring, $skiplog = false)
{
    pglib_transaction("ROLLBACK");
    if (!defined("USER_NAME")) {
        define("USER_NAME", "Not Logged In");
    }
    $err = DATE_LOGGING . " - " . SELF . " - " . USER_NAME . " - {$errstring}";
    if (pg_ErrorMessage()) {
        $err .= " - " . pg_ErrorMessage();
    }
    // log error to file
    if ($skiplog === false && ($fd = cfs::fopen("error_log", 'a'))) {
        if (cfs::fwrite($fd, "{$err}\n")) {
            $errlog_msg = "Error has been logged. Please notify the administrator.";
        } else {
            $errlog_msg = "Error writing to error log. Please notify the administrator.";
        }
        cfs::fclose($fd);
    } else {
        $errlog_msg = "Error opening error log. Please notify the administrator.";
    }
    $OUTPUT = "{$errstring} {$errlog_msg}";
    require relpath("template.php");
}
 function metadata($table = "", $iArr = 0)
 {
     $count = 0;
     $id = 0;
     $res = array();
     if ($table) {
         $this->connect();
         $id = pg_exec($this->conn, "select * from {$table}");
         if ($id < 0) {
             $this->Error = pg_ErrorMessage($id);
             $this->Errno = 1;
             $this->halt("Metadata query failed.");
         }
     } else {
         $id = $this->rs[$iArr];
         if (!$id) {
             $this->halt("No query specified.");
         }
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res['fields'][$i]["name"] = pg_FieldName($id, $i);
         $res['fields'][$i]["type"] = pg_FieldType($id, $i);
         $res['fields'][$i]["pkey"] = "0";
     }
     $this->query("select a.attname,    t.typname, case when a.attlen = -1 then 0 " . "else a.attlen end + case when a.atttypmod = -1 then 0 " . "else (a.atttypmod - 4) end ," . "case when d.description isnull THEN a.attname else d.description end , " . "a.attnum from pg_class c " . "inner join pg_attribute a ON (c.oid = a.attrelid AND a.attnum > 0) " . "INNER JOIN pg_type t ON (a.atttypid = t.oid) " . "LEFT OUTER JOIN pg_description d ON (c.relfilenode = d.objoid AND a.attnum = d.objsubid) " . "where c.relname = '" . $table . "' order by a.attnum");
     for ($i = 0; $i < $this->numrecords(); $i++) {
         $res['fields'][$i]["size"] = $this->f($i, 2);
         $res['fields'][$i]["desc"] = $this->f($i, 3);
     }
     $j = 0;
     for ($i = 0; $i < $count; $i++) {
         $this->query("SELECT relname, indkey[" . $i . "] " . "FROM pg_catalog.pg_index join pg_catalog.pg_class " . "ON pg_index.indrelid = pg_class.oid " . "WHERE indisprimary=true " . "AND relname = '" . $table . "';", 1);
         if ($this->f(0, 1, 1) != "0") {
             $res['fields'][$this->f(0, 1, 1) - 1]["pkey"] = "1";
             $res['pkey'][$j++] = pg_FieldName($id, $this->f(0, 1, 1) - 1);
         }
     }
     if ($table) {
         pg_FreeResult($id);
     }
     $this->query(' SELECT cl.relname AS table_name, a.attname AS column_name, ' . 'clf.relname AS foreign_table_name, af.attname AS foreign_column_name ' . 'FROM pg_attribute a ' . 'JOIN pg_class cl ON a.attrelid = cl.oid AND cl.relkind = \'r\'::"char" ' . 'JOIN pg_namespace n ON n.oid = cl.relnamespace ' . 'JOIN pg_constraint ct ON a.attrelid = ct.conrelid AND ct.confrelid <> 0::oid ' . 'AND ct.conkey[1] = a.attnum ' . 'JOIN pg_class clf ON ct.confrelid = clf.oid AND clf.relkind = \'r\'::"char" ' . 'JOIN pg_namespace nf ON nf.oid = clf.relnamespace ' . 'JOIN pg_attribute af ON af.attrelid = ct.confrelid AND af.attnum = ct.confkey[1] ' . 'WHERE cl.relname = \'' . $table . '\';');
     for ($i = 0; $i < $this->numrecords(); $i++) {
         $res['foreign'][$i]["idcol"] = $this->f($i, 'column_name');
         $res['foreign'][$i]["foretable"] = $this->f($i, 'foreign_table_name');
         $res['foreign'][$i]["forecol"] = $this->f($i, 'foreign_column_name');
     }
     $this->disconnect();
     return $res;
 }
 function GetLastInsertID($sTable)
 {
     @($res = pg_Exec($this->conn, "select currval('seq_{$sTable}')"));
     if ($res) {
         $Record = @pg_fetch_array($res, 0);
         @pg_FreeResult($res);
         return $Record[0];
     }
     trigger_error("Error getting last insert ID for table {$sTable}! " . pg_ErrorMessage());
     return -1;
 }
Beispiel #24
0
 function _generate_xml_postgre($query_string, $dbname = "mysql", $user = "******", $password = "", $host = "localhost")
 {
     /*if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS']))
             {
                 header('Content-Type: text/plain');
             }
     		else
             {
     		    header('Content-Type: application/download');
                 header('Content-Disposition: attachment; filename=dump.xml');
     		} */
     if (!($conn = $this->_db_connect($dbname, $user, $password, $host))) {
         die("Error. Cannot connect to Database.");
     } else {
         $result = pg_query($conn, $query_string);
         if (!$result) {
             die("Could not perform the Query: " . pg_ErrorMessage($result));
         } else {
             $file = "";
             $crlf = $this->_define_newline();
             $this->_generate_pgxml($result);
         }
     }
 }
Beispiel #25
0
 function metadata($table)
 {
     $count = 0;
     $id = 0;
     $res = array();
     $this->connect();
     $id = pg_exec($this->Link_ID, "select * from {$table}");
     if ($id < 0) {
         $this->Error = pg_ErrorMessage($id);
         $this->Errno = 1;
         $this->halt("Metadata query failed.");
     }
     $count = pg_NumFields($id);
     for ($i = 0; $i < $count; $i++) {
         $res[$i]["table"] = $table;
         $name = pg_FieldName($id, $i);
         $res[$i]["name"] = $name;
         $res[$i]["type"] = pg_FieldType($id, $i);
         //zot:  phplib is wrong, $name in field size should be $i
         //Mike got the line above corrected.
         $res[$i]["len"] = pg_FieldSize($id, $i);
         $res[$i]["flags"] = "";
     }
     pg_FreeResult($id);
     return $res;
 }