[PHP-dev 495] PEARのDB接続

m.awano php-dev@php.gr.jp
Tue, 10 Sep 2002 21:00:20 +0900


This is a multi-part message in MIME format.

------=_NextPart_000_001E_01C2590D.129E5B10
Content-Type: text/plain;
	charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit

はじめまして、淡野といいます。

さっそくですが、PEARをつかってDB接続をしたいのですがうまくいきません。
PEARを使わない場合うまくつながります。
はまってしまっているので教えてください。

ちなみに
turbolinux8
php4.1.2
です。
インストール状態のまま使っています。


・下記のソースを実行すると
require_once('/usr/lib/php/php/DB.php');
$dsn = "pgsql://awano: @localhost:5432/test01";
$db = DB::connect($dsn);
print_r($db);

・これがでます。
db_error Object ( [error_message_prefix] => [mode] => 1 [level] => 1024
[code] => -24 [message] => DB Error: connect failed [userinfo] =>
[nativecode= Warning: Unable to connect to PostgreSQL server: could not
connect to server: Connection refused Is the server running on host
localhost and accepting TCP/IP connections on port 5432? in
/usr/lib/php/php/DB/pgsql.php on line 118 ] ** pgsql://awano:
@localhost:5432/test01 [callback] => ) aaa

・PEARを使わない場合うまくつながります。
$dh = pg_connect("dbname=test01 user=awano password= hostname=localhost
port=5432") or die('not conegrantct');
$result = pg_EXEC($dh,"select * from test1");
$data = pg_fetch_array($result,0);
print $data[0];

------=_NextPart_000_001E_01C2590D.129E5B10
Content-Type: text/html;
	charset="iso-2022-jp"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-2022-jp">
<META content=3D"MSHTML 5.50.4919.2200" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT =
size=3D2>=1B$B$O$8$a$^$7$F!"C8Ln$H$$$$$^$9!#=1B(B</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT =
size=3D2>=1B$B$5$C$=3D$/$G$9$,!"=1B(BPEAR=1B$B$r$D$+$C$F=1B(B</FONT><FONT=
 size=3D2>DB=1B$B@\B3$r$7$?$$$N$G$9$,=1B(B</FONT><FONT=20
size=3D2>=1B$B$&$^$/$$$-$^$;$s!#=1B(B</FONT></DIV>
<DIV><FONT =
size=3D2>PEAR=1B$B$r;H$o$J$$>l9g$&$^$/$D$J$,$j$^$9!#=1B(B</FONT></DIV>
<DIV><FONT =
size=3D2>=1B$B$O$^$C$F$7$^$C$F$$$k$N$G65$($F$/$@$5$$!#=1B(B</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>=1B$B$A$J$_$K=1B(B</FONT></DIV>
<DIV><FONT size=3D2>turbolinux8</FONT></DIV>
<DIV><FONT size=3D2>php4.1.2</FONT></DIV>
<DIV><FONT size=3D2>=1B$B$G$9!#=1B(B</FONT></DIV>
<DIV><FONT =
size=3D2>=1B$B%$%s%9%H!<%k>uBV$N$^$^;H$C$F$$$^$9!#=1B(B</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>=1B$B!&2<5-$N%=3D!<%9$r<B9T$9$k$H=1B(B</FONT></DIV>
<DIV><FONT size=3D2>require_once('/usr/lib/php/php/DB.php');<BR>$dsn =3D =

"pgsql://awano: @localhost:5432/test01";<BR>$db =3D=20
DB::connect($dsn);<BR>print_r($db);</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>=1B$B!&$3$l$,$G$^$9!#=1B(B</FONT></DIV>
<DIV><FONT size=3D2>db_error Object ( [error_message_prefix] =3D&gt; =
[mode] =3D&gt; 1=20
[level] =3D&gt; 1024 [code] =3D&gt; -24 [message] =3D&gt; DB Error: =
connect failed=20
[userinfo] =3D&gt; [nativecode=3D Warning: Unable to connect to =
PostgreSQL server:=20
could not connect to server: Connection refused Is the server running on =
host=20
localhost and accepting TCP/IP connections on port 5432? in=20
/usr/lib/php/php/DB/pgsql.php on line 118 ] ** pgsql://awano:=20
@localhost:5432/test01 [callback] =3D&gt; ) aaa&nbsp; </FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT =
size=3D2>=1B$B!&=1B(BPEAR=1B$B$r;H$o$J$$>l9g$&$^$/$D$J$,$j$^$9!#=1B(B<BR>=
$dh =3D pg_connect("dbname=3Dtest01=20
user=3Dawano password=3D hostname=3Dlocalhost port=3D5432") or die('not=20
conegrantct');<BR>$result =3D pg_EXEC($dh,"select * from =
test1");<BR>$data =3D=20
pg_fetch_array($result,0);<BR>print $data[0];</FONT></DIV></BODY></HTML>

------=_NextPart_000_001E_01C2590D.129E5B10--