Limit postgresql query results
От | Blake Starkenburg |
---|---|
Тема | Limit postgresql query results |
Дата | |
Msg-id | 025e01bee805$38b02120$ef3efdd0@ibm обсуждение исходный текст |
Список | pgsql-general |
Hello, I am using PostgreSQL 6.3 and PHP. I am trying to build a query that only returns 20 results at a time, with a "next" link at the bottom of the query results for the next 20. Someone suggested to me that I use the below block of code (pg_Exec ($conn, "set QUERY_LIMIT='20'");). How would I use this in the below code I'm already using to connect to and query the DB? And does anyone maybe have any better ideas of going about this task? CODE I WAS GIVEN TO USE --------------------------------------------------------------------- pg_Exec ($conn, "set QUERY_LIMIT='20'"); --------------------------------------------------------------------- THE CODE I AM USING NOW --------------------------------------------------------------------- <SCRIPT language="PHP"> $conn = pg_Connect("Localhost", "5432", "", "", "contacts"); if (!$conn) { echo "An error occurred.\n"; exit; } $result = pg_Exec($conn, "SELECT* FROM contacts_list"); if (!$result) { echo "An error occurred.\n"; exit; } $num = pg_NumRows($result); $i = 0; while ($i < $num) { echo "<TR><TD><font>"; echo pg_Result($result, $i, "personal_id"); echo "</font></TD><TD><font>"; echo pg_Result($result, $i, "name"); echo "</font></TD><TD><font>"; echo pg_Result($result, $i, "address"); echo "</font></TD><TD><font>"; echo pg_Result($result, $i, "city"); echo "</font></TD><TD><font>"; echo pg_Result($result, $i, "state"); echo "</font></TD><TD><font>"; echo pg_Result($result, $i, "zip_code"); echo "</font></center></TD><TD><center><font>"; echo pg_Result($result, $i, "phone_number"); echo "</font></center></TD></TR>"; $i++; } pg_FreeResult($result); pg_Close($conn); </script> --------------------------------------------------------------------- Thank you everyone for your help
В списке pgsql-general по дате отправления: