[PHP-users 13622] PEAR$B$G%U%#!<%k%I>pJs$r(B$B<hF@$9$k$H%l%3!<%I?t$,(B$B<hF@$G$-$J$$(B

Kiyohito Mizusako php-users@php.gr.jp
Fri, 28 Feb 2003 11:12:24 +0900


$B$*@$OC$K$J$C$F$*$j$^$9!#(Bmizusako$B$G$9!#(B

$B:n6H4D6-(B
Turbolinux Server 6.5
PHP 4.2.1
PostgreSQL 7.2.1

$B!!(BPEAR$B$K$F(BDB$B$H$d$j$H$j$r$7$F$$$k$N$G$9$,!"%U%#!<%k%IL>$N<hF@$r9T$&$H!"(B
$B%l%3!<%I?t$,<hF@$G$-$J$$8=>]$,=P$F$7$^$$$^$9!#(B
$B2?$+$NA`:n$,B-$j$J$$$h$&$J5$$,$9$k$N$G$9$,!"$=$l$,2?$+$,$h$/J,$+$i$J$$>u(B
$BBV$G$9!#(B
$B2?$,860x$+!"$*$o$+$j$K$J$kJ}$,$$$i$C$7$c$$$^$7$?$i!"$465<x4j$($J$$$G$7$g(B
$B$&$+!)(B

$B!];29M!](B
common.php$B!J@\B3MQ(BPHP)

$db = DB::connect($dsn);
$B!!!!(Bif(DB::isError($db)){
$B!!!!(Becho '$B@\B3$K<:GT$7$^$7$?!#(B<br>';
$B!!!!(Bexit ( $db->getMessage() );
}


test.php$B!J%G!<%?I=<(MQ!K(B

include_once 'common.php';

$sql = "select * from test";
$result = $db->query($sql);  // SQL$B<B9T(B

$field_cnt  = $result->numcols();    // $B%U%#!<%k%I?t$N<hF@(B

$field_name = $result->tableinfo();  // $B%U%#!<%k%IL>$N<hF@(B
for($i=0; $i<$field_cnt; $i++){
$B!!!!(Bprint '$B%U%#!<%k%IL>(B:[" . $field_name[$i]["name"] . "]<br>";
}

$result_cnt = $result->numrows(); // SQL$B$N7k2L7o?t$N<hF@(B

$B0J2<N,(B


$B>e5-$N(Btest.php$B$N%U%#!<%k%IL>$N<hF@$N%m%8%C%/$rF~$l$k$H!"(BSQL$B$N7k2L7o?t$N(B
$B7k2L$,%*%V%8%'%/%HJQ?t$K$J$C$F$7$^$$$^$9!#(B
$B5U$KF~$l$J$$$H!"IaDL$K%l%3!<%I?t$,JV$C$F$-$^$9!#(B

PEAR$B$N%^%K%e%"%k(B($B2<5-%5%$%H!K$r;29M$K$7$F$$$^$9!#(B
http://pear.php.net/manual/ja/core.db.php

_/_/_/_/_/_/_/_/_/_/_/_/_/
Mizusako
mizusako@southwave.co.jp
_/_/_/_/_/_/_/_/_/_/_/_/_/_