On Tue, Jun 9, 2009 at 10:35 PM, Tory M Blue <tmblue(at)gmail(dot)com> wrote:
>
> Thanks guys, the problem with copy from or to is that it creates an
> array and thus puts a load of stuff in memory, it's possible the file
> will get huge and I can't take that memory hit.
>
> I'll look again and see if I missed something
>
> Thanks
> Tory
>
It's not hard to do some streaming with copy (untested):
$conn = pg_pconnect("dbname=foo");
$fd = fopen('file.dat', 'r');
while (!feof($fd)) {
pg_put_line($conn, fgets($fd));
}
fclose($fd);
pg_put_line($conn, "\\.\n");
pg_end_copy($conn);
http://ru.php.net/manual/en/function.pg-put-line.php