Skip to content

Instantly share code, notes, and snippets.

@jkhin
Created July 11, 2014 14:14
Show Gist options
  • Save jkhin/bdbb6560734c89b568b5 to your computer and use it in GitHub Desktop.
Save jkhin/bdbb6560734c89b568b5 to your computer and use it in GitHub Desktop.
Carga de un archivo CSV a postgres
<?
include '../conexion/conexion.php';
session_start();
$user=$_SESSION['id'];
echo $user;
//function copyCSV(){
pg_query("COPY nominas (nombre_completo, cedula, dependencia, cargo, cargo_profesional, fecha_ingreso, sueldo_mensual, prima_prof, prima_ant, bono_transporte, prima_hijo, prima_jerarquia, prima_responsabilidad, complemento_sueldo, prima_transporte, bono_alimentacion, bono_ayuda_famacia)
from '/var/www/intranet/class/Upload/test.csv'
WITH DELIMITER ';'
CSV HEADER");
//$nombrenom = pg_query("SELECT nombre FROM nominas WHERE nombre=$ci");
//}
//function pollNOMINA(){
$innerpoll="";
$poll = pg_query("SELECT a.id,a.cn_ldap,b.cedula FROM users a JOIN nominas b ON a.cn_ldap=b.cedula WHERE b.cedula=a.cn_ldap and a.id=$user");
$innerpoll = pg_fetch_array($poll);
echo "<pre>";
print_r($innerpoll);
echo "</pre>";
echo $innerpoll[1];
// return this->$innerpoll[2];
//}
//pollSESSION();
//pollNOMINA();
//copyCSV();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment