From: Adam Witney <awitney@sghms.ac.uk>
To: DeJuan Jackson <djackson@speedfc.com>
To: pgsql-php <pgsql-php@postgresql.org>
Subject: Re: PHP and COPY
Date: Sat, 16 Aug 2003 13:21:53 +0100
Message-ID: <BB63E071.226B6%awitney@sghms.ac.uk> (raw)
In-Reply-To: <3F3D235D.6090005@speedfc.com>
Try something along these lines..... (this snippet is untested but should
get you started)
$dbh = pg_connect($connstr);
$sql = "COPY table (field1, field2, field3) from stdin;";
$result = pg_query($dbh, $sql);
$data = "blah\tblah\tblah\n";
$stat = pg_put_line($dbh, $data);
if(!$stat)
{
echo "copy failed: ".pg_errormessage($dbh)."<br>\n";
}
pg_put_line($dbh, "\\.\n");
pg_end_copy($dbh);
> Does anyone know how to execute a COPY from PHP?
> I keep getting parse errors on all the data.
>
> PHP 4.3.2
> PostgreSQL 7.3.4
>
> example:
>
> CREATE table tmp(data text);
>
> COPY tmp FROM STDIN;
> test1
> test2
> test3
> \.
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: awitney@sghms.ac.uk, djackson@speedfc.com
Subject: Re: PHP and COPY
In-Reply-To: <BB63E071.226B6%awitney@sghms.ac.uk>
References: <3F3D235D.6090005@speedfc.com> <BB63E071.226B6%awitney@sghms.ac.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox