Try this --
after replacing Fabrik element and DB columns with yours:
Code:
<?php
$expedient = '{table___name_element}';
// get "deute anual" sum
$mydb = JFactory::getDbo();
$query = $mydb->getQuery(true);
$query->select('SUM('.$mydb->quoteName('column_name_of_deute_anual').')');
$query->from($mydb->quoteName('gpimpagats'));
$query->where($mydb->quoteName('column_name_of_expedient').' = '.$mydb->quote($expedient));
$mydb->setQuery($query);
$total_deute_anual = $mydb->loadResult();
// return result (in all rows)
return $total_deute_anual;
?>
Syntax:
https://docs.joomla.org/Selecting_data_using_JDatabase
As per Wiki it's recommended to use "$mydb" or else; not just "$db" as that may cause trouble in Fabrik.
good...
I still can't get it.
<?php
$expedient = '{
gpimpagats___gp_imp_cuotaimpagat}';
// get "deute anual" sum
$mydb = JFactory::getDbo();
$query = $mydb->getQuery(true);
$query->select('SUM('.$mydb->quoteName('gp_imp_totaldeute').')');
$query->from($mydb->quoteName('gpimpagats');
$query->where($mydb->quoteName('
gpimpagats___gp_imp_cuotaimpagat').' = '.$mydb->quote($expedient));
$mydb->setQuery($query);
$total_deute_anual = $mydb->loadResult();
// return result (in all rows)
return $total_deute_anual;
?>
I get this error ...
0 syntax error, unexpected '<', expecting end of file
I have reviewed ... and tried several changes and nothing ...
I have also looked to remove this line ... to limit errors
// $ query-> where ($ mydb-> quoteName ('gpimpagats ___ gp_imp_cuotaimpagat'). '='. $ mydb-> quote ($ expedient));
And it gives me the same mistake.
I have doubts about the data I should have to write in the fields marked in red ...
I begin to be confused and thick.
explanatory summary
database name (I understand that it should not be written)
table name "gpimpagats"
element name of the rows to SUM "gpimpagats___gp_imp_cuotaimpagat"
I also attach another image ... of the elements ... to clarify
thank you thank you for the time spent ...