Re: Horde_Db_Adapter count matching records

Sebastian Birnbach <[email protected]> Mon, 16 Jul 2018 11:16:09 +0200
Newsgroups gmane.comp.horde.devel
Message-ID <CACTNBFNQKokCuFG+CPKzd0edsSk0fZfC0vQ=0S07fuVdjxzNow@mail.gmail.com>
SOLVED, please disregard previous mail.

For the archives: COUNT() is a SQL function; for calling there must not be
a space before the brackets:
COUNT(*) <-- OK
COUNT (*) <-- NOK

  birnbacs

2018-07-16 9:59 GMT+02:00 Sebastian Birnbach <[email protected]>:

> All,
>
> I am using Horde_Db_Adapter for querying a mySQL database; driver is
> mysqli. I need to get the number of results for a query in order to display
> them pagewise.
>
> $adapter = $injector->getInstance('Horde_Db_Adapter');
> $query = "SELECT (*) FROM my_table WHERE variable = condition";
> $res = $adapter->select($query);
> $numres = iterator_count($res);
>
>
> If results are plenty, retrieving all of them may put a huge load on the
> webserver, so I tried database counting:
>
> $query = "SELECT COUNT (my_table.variable) AS myvar FROM my_table WHERE
> variable = condition";
>
> but  wthout luck:
>
> QUERY FAILED: FUNCTION horde.COUNT does not exist.
>
>
> Question: is there a way of determining, with the Horde DB adapter, how
> many records match a given query without actually retrieving the records?
>
>
> Thanks
>
>   birnbacs
>
-- 
dev mailing list
Frequently Asked Questions: http://wiki.horde.org/FAQ
To unsubscribe, mail: [email protected]