Exemple #1
0
 public function freeResult($name)
 {
     if (isset($this->result[$name])) {
         pg_FreeResult($this->result[$name]);
         unset($this->result[$name]);
     }
 }
function listarErrores($db, $date_ini)
{
    $query = "SELECT \r\n\t\t\t  id_migracion,\r\n\t\t\t  verificado,\r\n\t\t\t  consulta,\r\n\t\t\t  operacion,\r\n\t\t\t  migracion,\r\n\t\t\t  fecha_reg,\r\n\t\t\t  fecha_mig,\r\n\t\t\t  desc_error\r\n\t\t\tFROM \r\n\t\t\t  migracion.tmig_migracion  m\r\n\t\t\tWHERE  m.migracion = 'falla' \r\n\t\t\tand   (fecha_correo  <= '{$date_ini}' \r\n\t\t\tor  fecha_correo  is NULL);";
    echo $query;
    echo "<BR>FECHA  ---> " . date("Y/m/d H:i:s") . "<BR>";
    $query_upd = "\nUPDATE \r\n\t          migracion.tmig_migracion set \r\n\t          fecha_correo = '" . date("Y/m/d H:i:s") . "'\r\n\t          WHERE\r\n\t\t\t     id_migracion = ";
    $salida = array();
    if ($result = pg_query($db, $query)) {
        while ($row = pg_fetch_array($result)) {
            $consulta = $query_upd . $row["id_migracion"] . ';';
            echo $consulta;
            pg_query($db, $consulta);
            //enviarCorreo($row['consulta'],$row['desc_error'],$row['operacion'],$row['fecha_mig']);
        }
        //Libera la memoria
        pg_FreeResult($result);
    } else {
        print 'Error al ejecutar funcion. ' . pg_last_error($db);
    }
    return $salida;
}
Exemple #3
0
 function free()
 {
     // free the postgresql result tables
     return @pg_FreeResult($this->result);
 }
function sql_free_result($res)
{
    global $dbtype;
    switch ($dbtype) {
        case "MySQL":
            $row = mysql_free_result($res);
            return $row;
            break;
        case "mSQL":
            $row = msql_free_result($res);
            return $row;
            break;
        case "postgres":
        case "postgres_local":
            $rows = pg_FreeResult($res->get_result());
            return $rows;
            break;
        case "ODBC":
        case "ODBC_Adabas":
            $rows = odbc_free_result($res);
            return $rows;
            break;
        case "Interbase":
            echo "<BR>Error! PHP dosen't support ibase_numrows!<BR>";
            return $rows;
            break;
        case "Sybase":
            $rows = sybase_free_result($res);
            return $rows;
            break;
    }
}
 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;
 }
Exemple #6
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;
 }
Exemple #7
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;
 }
 function clean_results()
 {
     if ($this->Query_ID != 0) {
         pg_FreeResult($this->Query_ID);
     }
 }
 function free_result($query_id)
 {
     return pg_FreeResult($query_id);
 }
 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 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;
         $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;
 }
 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;
 }