From: | Vince Vielhaber <vev(at)michvhf(dot)com> |
---|---|
To: | Devrim GUNDUZ <devrim(at)oper(dot)metu(dot)edu(dot)tr> |
Cc: | Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>, <pgsql-php(at)postgresql(dot)org> |
Subject: | Re: Connecting PostgreSQL db using Pear |
Date: | 2002-10-04 17:39:47 |
Message-ID: | Pine.BSF.4.40.0210041333470.81546-100000@paprika.michvhf.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-php |
On Fri, 4 Oct 2002, Devrim GUNDUZ wrote:
>
> Hi,
>
> (sorry for the late response...)
>
> On 2 Oct 2002, Andrew McMillan wrote:
>
> > Can you confirm that the postmaster is started with support for TCP
> > connections? It is possible that in other instances you are connecting
> > via unix sockets.
>
> Good point. Tried this connection parameters in two different servers.
> One of them uses Unix domain sockets, the other has a tcp_ip port open...
>
> Anyway, does someone has an example of PostgreSQL + Pear?
Strangely enough, yes. I just did it this week.
// include pear's db stuff
require_once 'DB.php';
// set up your data source
$dsn = "pgsql://vev(at)localhost/mydatabase";
// connect to your data source
$db = DB::connect($dsn, false);
if (DB::isError($db)) {
die ($db->getMessage());
}
// make your query
$query = "select a from foo";
$res = $db->query($query);
if (DB::isError($res)) {
echo("$query<P>\n");
die ($res->getMessage());
}
// display your results
while ($row = $res->fetchRow())
echo("$row[0]<br>\n");
// disconnect and return
$db->disconnect();
return;
Quite simple actually. I was surprised. The docs make it look
a whole lot harder than it is.
Vince.
--
==========================================================================
Vince Vielhaber -- KA8CSH email: vev(at)michvhf(dot)com http://www.pop4.net
56K Nationwide Dialup from $16.00/mo at Pop4 Networking
http://www.camping-usa.com http://www.cloudninegifts.com
http://www.meanstreamradio.com http://www.unknown-artists.com
==========================================================================
From | Date | Subject | |
---|---|---|---|
Next Message | Devrim GUNDUZ | 2002-10-04 18:16:52 | Re: Connecting PostgreSQL db using Pear |
Previous Message | Devrim GUNDUZ | 2002-10-04 17:27:04 | Re: Connecting PostgreSQL db using Pear |