Count results from another database

mzanotto

New Member
Hi,
as in title, I need to query another database and count the results.

Which is the better way?
I thought to use calc element but how can I connect db object to external database?

Thanks,
Max
 
Add the external database to the Fabrik Connections. Make a note of the ID it gets.

In your code ...

Code:
// Replace 2 with the ID of your connection
$myDb = FabrikWorker::getDbo(false, 2);
// now it's just standard J! database API stuff, and probably some Fabrik placeholders
$something = '{yourtable___something}';
$myQuery = $myDb->getQuery(true);
$myQuery->select('COUNT(foo)')->from('othertable')->where('something = ' . $myDb->quote($something));
$myDb->setQuery($myQuery);
return $myDb->loadResult();

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top