Horde_Db_Adapter count matching records

Sebastian Birnbach <[email protected]> Mon, 16 Jul 2018 09:59:54 +0200
Newsgroups gmane.comp.horde.devel
Message-ID <CACTNBFOdCw4YW+a_0kJ-CObOhHtCemhCoLoY0u06v25g6uNr4w@mail.gmail.com>
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]