note 66408 added to function.pg-query
| From: | zoliatmakettinfo dot hu at osu1 dot php dot net | Date: | Sun, 21 May 2006 15:07:22 +0000 |
| Subject: | note 66408 added to function.pg-query | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111785@lists.php.net to get a copy of this message | ||
It would be better this way:
<?php
$result=pg_query($conn, "SELECT COUNT(*) AS rows FROM x WHERE a=b;");
if (!$result) {
echo "query did not execute";
}
if ($line = pg_fetch_assoc($result)) {
if ($line['rows'] == 0) {
echo "0 records"
}
}
else {
while ($row = pg_fetch_array($result)) {
//do stuff with $row
}
}
?>
This solution doesn't raise the load of the system with the move of matching rows (perhaps 0,1,
perhaps 100, 1000, ... rows)
----
Server IP: 195.70.37.52
Probable Submitter: 193.226.223.226
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.pg-query.php
Edit -- http://master.php.net/note/edit/66408
Del: integrated -- http://master.php.net/note/delete/66408/integrated
Del: useless -- http://master.php.net/note/delete/66408/useless
Del: bad code -- http://master.php.net/note/delete/66408/bad+code
Del: spam -- http://master.php.net/note/delete/66408/spam
Del: non-english -- http://master.php.net/note/delete/66408/non-english
Del: in docs -- http://master.php.net/note/delete/66408/in+docs
Del: other reasons-- http://master.php.net/note/delete/66408
Reject -- http://master.php.net/note/reject/66408
Search -- http://master.php.net/manage/user-notes.php