pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter <peterh@600ml.com.au>
To: PostgreSQL PHP <pgsql-php@postgresql.org>
Subject: total row count for selects with a limit
Date: Tue, 27 Nov 2001 08:47:24 +1100
Message-ID: <005001c176c3$ef8d4e00$0300000a@600mlPeterPC1> (raw)

Hi there,

what seems to be the best way of getting the total row number on select queries with a limit on them?

What I am currently thinking of doing is building select queries dynamically and wrapping all selected fields into the count() function without the limit 

somthing like:

select a,b,c from table limit 10

and for total count

select count(a,b,c) from table

and a function to build the select query with parameters such as

function build_select($table, $cols=array(), $limit, $orderby, $where) { ... }

I am going in the right direction? Instead of one query I need 2 is there a way of making it just one query?

thanks for any help

regards, Peter

Message-ID: <005001c176c3$ef8d4e00$0300000a@600mlPeterPC1>
Permalink:  ../005001c176c3$ef8d4e00$0300000a@600mlPeterPC1/
Also on:    postgresql.org/message-id/005001c176c3$ef8d4e00$0300000a@600mlPeterPC1

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: peterh@600ml.com.au
  Subject: Re: total row count for selects with a limit
  In-Reply-To: <005001c176c3$ef8d4e00$0300000a@600mlPeterPC1>
  References: <005001c176c3$ef8d4e00$0300000a@600mlPeterPC1>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox