Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: pg_num_rows - Manual
[go: Go Back, main page]

PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<pg_num_fieldspg_options" width="11" height="7"/>
view the version of this page
Last updated: Sun, 07 May 2006

pg_num_rows

(PHP 4 >= 4.2.0, PHP 5)

pg_num_rows -- 行数を返す

説明

int pg_num_rows ( resource result )

pg_num_rows() は、PostgreSQL の結果リソースの 行数を返します。

注意: この関数は、以前は pg_numrows() と呼ばれていました。

パラメータ

result

pg_query(), pg_query_params() あるいは pg_execute() から返される PostgreSQL の クエリ結果リソース。

返り値

結果の行数を返します。エラー時には -1 を返します。

例 1. pg_num_rows() の例

<?php
$result
= pg_query($conn, "SELECT 1");

$rows = pg_num_rows($result);

echo
$rows . " row(s) returned.\n";
?>

上の例の出力は以下となります。

1 row(s) returned.



add a note add a note User Contributed Notes
pg_num_rows
php-docs (at) radev (dot) net
24-Mar-2005 12:16
Yet even simpler example:

$query = "SELECT * FROM atable";
$result = pg_query($query);

if (pg_num_rows($result)>0) {
  while($row=pg_fetch_object($result) {
   echo $row->first_column;
   echo $row->second_column;
   ....
   echo $row->last_column;
  }
}
else {
  echo "The query did not return any data!";
}
aron at lurie dot biz
03-Nov-2003 10:23
Simple example

$sql = "select * from YOURTABLE";
$result = pg_query($sql);
$rows = pg_num_rows($result);
for ($i = 0; $i < $rows; $i++)
{
   $data = pg_fetch_object($result, $i);
   echo "$data->COLUMNNAME";
}
flavio AT catalani.net
15-Jan-2003 03:39
simple pg_num_fields & pg_num_rows example.

$result = pg_query($conn, $string);

while($arr = pg_fetch_array ($result)) {
     for ($x=0;$x<=pg_num_fields($result);$x++)
           print $arr[$x] . " ";
     print "\n";
}

adapted (stolen) from php manual ;)
sean at seattleone dot com
22-Oct-2002 11:27
Simple Example:

$result = pg_query($conn_id, $query);
echo pg_num_rows($result);

<pg_num_fieldspg_options" width="11" height="7"/>
 Last updated: Sun, 07 May 2006
show source | credits | sitemap | contact | advertising | mirror sites 
Copyright © 2001-2006 The PHP Group
All rights reserved.
This mirror generously provided by: PacketBusiness, Inc.
Last updated: Wed Jun 28 13:19:26 2006 JST