Calc element ? query syntax

Can?t seem to get the syntax right :/
I would appreciate some help to include some more criteria in my query.

First of all I would like to ORDER BY ?percentage? .
If possible I would also like to GROUP BY ?e_group_eng?
(so that all ?sub_component_eng? are listed according to ?e_group_eng?)
I would appreciate some help to get the syntax right.
Thanks!

// Get a db connection.
$db = JFactory::getDbo();

// Create a new query object.
$query = $db->getQuery(true);

$query
->select(array('percentage' , 'e_group_eng' , 'sub_component_eng'))
->from('ingredients_relation')
->where('component = ' . $db->quote('{product_labels___component_raw}'));

// Assign the query to the db
$db->setQuery($query);

// Load the results as an array of objects.
$rows = $db->loadObjectList();

// Return the list (with "e_group_eng" if present).
$list = array();
foreach ($rows as $row)
{
if (strlen($row->e_group_eng)>1)
$list[] = $row->percentage . " % " . $row->e_group_eng . ": " . $row->sub_component_eng . ', ';
else
$list[] = $row->percentage . " % " . $row->sub_component_eng . ', ';
}
return implode($list);

BRGDS,
Michael
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top