Hi
I have created a DataObjectDecorator that contains a SQLQuery it all works until i add the
HERE Statement in. the DataObjectDecorator decorate a DataObject called Quote and Quote has a Has_Many Relationship to Recipe.
I want to sum the weights in recipe where the quoteID in Recipe is the same as the Quote ID.
<?php
class ExQuote extends DataObjectDecorator {
function TotalWeight()
{
$sqlQuery = new SQLQuery(
"SUM(Recipe.Weight)", // Select
"Recipe", // From
"Recipe.QuoteID =" . $this->Owner->ID //Where
);
$totalWeight = $sqlQuery->execute()->value();
return $totalWeight;
}
public function updateCMSFields(FieldSet &$fields){
$fields->addFieldToTab("Root.Checks", new LiteralField ( '','Total Weight'));
$fields->addFieldToTab("Root.Checks", new LiteralField ('', $this->TotalWeight()));
}
}
can anyonre help please?