Created
May 3, 2011 21:43
-
-
Save roskoff/954328 to your computer and use it in GitHub Desktop.
Exporta documentos del tipo "large object" almacenados en una base de datos PostgreSQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Datos de la conexion | |
$database = pg_connect("host='192.168.0.100' dbname='database' user='codusr' password='pass'"); | |
// Para utilizar pg_lo_export(), debemos llamarla dentro de un transaction block | |
pg_query($database, "begin"); | |
// Consulta SQL, documento es de tipo lo (large object) | |
$result = pg_query($database, "SELECT documento, nombre_en_disco from tabla_de_documentos"); | |
while($row = pg_fetch_row($result)){ | |
list($oid, $nombre) = $row; | |
echo "Documento: " . $nombre . " ---> "; | |
if(pg_lo_export($database, $oid, "/tmp/documentos/$nombre")){ | |
echo "Exportado.<br>"; | |
}else { | |
echo "NO Exportado.<br>"; | |
} | |
} | |
// Confirmamos la transaccion | |
pg_query($database, "commit"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment