count the number of times another field was repeated

mvilela

Member
I used this script in a calculation field to count the number of times another field was repeated.
I don't know if it's because I updated to the latest versions of Joomla/Fabrik that it doesn't work.
Any suggestion

$fac = '{hora}';
$mydb = JFactory::getDbo();
$query = $mydb->getQuery(true);
$query->select('hora')
->from($mydb->quoteName ('aaa_aainscritos_hora'))
->where($mydb->quoteName('hora') . ' = ' . $mydb->quote($fac));
$mydb->setQuery($query);
$mydb->execute();
$somany = $mydb->getNumRows();
return $somany;

Fabrik 4.0Zeta
Joomla! 4.4.1 Stable [ Pamoja ] 28-November-2023 16:00 GMT
Linux cpp12.webserver.pt 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
10.6.16-MariaDB
 
I updated, but something must still be missing. As my programming knowledge is limited, I would appreciate your help.

$fac = '{hora}';
$mydb = Joomla\CMS\Factory::getContainer()->get('DatabaseDriver');
$query = $mydb->getQuery(true);
$query->select('hora')
->from($mydb->quoteName('aaa_aainscritos_hora'))
->where($mydb->quoteName('hora') . ' = ' . $mydb->quote($fac));
$mydb->setQuery($query);
$mydb->execute();
$somany = $mydb->getNumRows() ;
return $somany;
 
Was this ever working?
What is '{hora}'?
What "does not work"?
Do you have error reporting on?
Error messages?
Messages in your browser dev console?
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top