Esempio n. 1
0
function listOptions($dataset, $choixdef)
{
    global $database;
    $result = pg_Exec($database, "SELECT * FROM " . $dataset);
    $Nbr = pg_NumRows($result);
    for ($i = 0; $i < $Nbr; $i++) {
        $tablo[$i] = pg_Result($result, $i, 0);
    }
    if ($Nbr > 2) {
        sort($tablo);
    }
    echo "<select name=liste_" . $dataset . ">\n";
    for ($i = 0; $i < $Nbr; $i++) {
        if ($tablo[$i] == $choixdef) {
            echo "  <option selected>" . $tablo[$i] . "</option>\n";
        } else {
            echo "  <option>" . $tablo[$i] . "</option>\n";
        }
    }
    echo "</select>\n";
    return 1;
}
Esempio n. 2
0
function fcdb_query_single_value($stmt)
{
    global $fcdb_sel, $fcdb_conn;
    set_error_handler("fcdb_error_handler");
    switch ($fcdb_sel) {
        case "PostgreSQL":
            $res = pg_Exec($fcdb_conn, $stmt);
            if (!$res) {
                build_fcdb_error("I cannot run a query: '{$stmt}'.");
            }
            $val = pg_Result($res, 0, 0);
            break;
        case "MySQL":
            $res = mysql_query($stmt, $fcdb_conn);
            if (!$res) {
                build_fcdb_error("I cannot run a query: '{$stmt}'.");
            }
            $val = mysql_result($res, 0, 0);
            break;
    }
    restore_error_handler();
    return $val;
}
function Sincronizar($db)
{
    $rows = 0;
    // Number of rows
    $qid = 0;
    // Query result resource
    // See PostgreSQL developer manual (www.postgresql.org) for system table spec.
    // Get catalog data from system tables.
    $sql = 'SELECT * FROM migracion.f_sincronizacion()';
    $qid = pg_Exec($db, $sql);
    // Check error
    if (!is_resource($qid)) {
        print 'Error en la Sincronizacion';
        return null;
    }
    $rows = pg_NumRows($qid);
    // Store meta data
    for ($i = 0; $i < $rows; $i++) {
        $res = pg_Result($qid, $i, 0);
        // Field Name
    }
    echo 'Sincronizacion terminada (' . $res . ')  - ' . date("m-d-Y H:i:s") . '<BR>';
    return $res;
}
Esempio n. 4
0
if (eregi("update", $submit)) {
    $query = "";
    reset($new);
    foreach ($new as $key => $value) {
        $query .= ", {$key} = '" . tidy($value) . "' ";
    }
    $query = substr($query, 2);
    $query = "UPDATE wu SET {$query} WHERE node_id = {$node_id} AND wu_by = {$session->user_no}; ";
} else {
    $fields = "";
    $values = "";
    if (!isset($node_id) || $node_id == 0) {
        $query = "SELECT nextval('infonode_node_id_seq');";
        $rid = awm_pgexec($dbconn, $query, "wu-action", false);
        if ($rid) {
            $node_id = pg_Result($rid, 0, 0);
            $query = "INSERT INTO infonode (node_id, nodename, created_by) ";
            $query .= "VALUES( {$node_id}, '" . tidy($nodename) . "', {$session->user_no} );";
            $rid = awm_pgexec($dbconn, $query, "wu-action", false);
        }
    }
    $new['node_id'] = $node_id;
    $new['wu_by'] = $session->user_no;
    reset($new);
    foreach ($new as $key => $value) {
        $fields .= ", {$key}";
        $values .= ", '" . tidy($value) . "' ";
    }
    $fields = substr($fields, 2);
    $values = substr($values, 2);
    $query = "INSERT INTO wu ({$fields}) VALUES({$values}); ";
Esempio n. 5
0
<?php

include "inc/always.php";
include "inc/tidy.php";
$user_no = "";
$query = "SELECT user_no FROM usr WHERE username=LOWER('{$l}') and password=LOWER('{$p}')";
$result = pg_Exec($dbconn, $query);
if (pg_NumRows($result) > 0) {
    $user_no = pg_Result($result, 0, "user_no");
}
$requests = "<p><small>";
if ("{$user_no}" != "") {
    $query = "SELECT DISTINCT request.request_id, brief, last_activity, ";
    $query .= "lookup_desc AS status_desc, severity_code ";
    $query .= "FROM request, request_interested, lookup_code AS status ";
    $query .= "WHERE request.request_id=request_interested.request_id ";
    $query .= "AND status.source_table='request' ";
    $query .= "AND status.source_field='status_code' ";
    $query .= "AND status.lookup_code=request.last_status ";
    $query .= "AND request_interested.user_no={$user_no} ";
    $query .= "AND request.active ";
    $query .= "AND request.last_status~*'[AILNRQA]' ";
    $query .= "ORDER BY request.severity_code DESC LIMIT 20; ";
    $result = pg_Exec($dbconn, $query);
    if (!$result) {
        error_log("wrms wap/inc/getRequests.php query error: {$query}", 0);
    }
    for ($i = 0; $i < pg_NumRows($result); $i++) {
        $thisrequest = pg_Fetch_Object($result, $i);
        $requests .= "<a href=\"wrms.php?id={$thisrequest->request_id}\">" . tidy($thisrequest->brief) . "</a><br/>\n";
    }
Esempio n. 6
0
 function insert_id($col = "", $tbl = "", $qual = "")
 {
     global $FC_Link_ID;
     if (!empty($FC_Link_ID)) {
         $this->Link_ID = $FC_Link_ID;
     }
     $ires = pg_Exec($this->Link_ID, "select {$col} from {$tbl} where {$qual}");
     if (!pg_Fetch_Row($ires, 0)) {
         return 0;
     }
     $iseq = pg_Result($ires, 0, "{$col}");
     pg_FreeResult($ires);
     return $iseq;
 }
Esempio n. 7
0
 /**
  * Return uniq id from the last insert,
  *
  * If param field is not provide it is guess with "id"+$tablename
  * if table param is not provide it search for $this->table.
  * if not enough information is found to create the sequence name
  * then it return 0.
  *
  * @param string $table  name of the table with the sequence
  * @param string $field name of the primary key used for the sequence
  *
  * @return integer insert_id
  */
 function getInsertId($table = "", $field = "")
 {
     if (strlen($table) > 0) {
         if (strlen($field) == "") {
             $field = "id" . $table;
         }
     } elseif (strlen($this->table) > 0) {
         $table = $this->table;
         $field = "id" . $table;
     }
     //$table = substr( $table, 0, 13) ;
     //$field = substr($field, 0, 13) ;
     if (strlen($table) > 0 && strlen($field) > 0) {
         $sequence = $table . "_" . $field . "_seq";
         $rquery = pg_query($this->dbCon->id, "SELECT currval('" . $sequence . "')");
         $this->insert_id = pg_Result($rquery, 0, 0);
         return $this->insert_id;
     } else {
         return 0;
     }
 }