3060 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 169 Views |
-
DatObjectDecoreator SQL Query Not working

18 September 2012 at 8:25pm
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?
-
Re: DatObjectDecoreator SQL Query Not working

18 September 2012 at 8:40pm
You want $this->owner, not $this->Owner. Properties are case sensitive.
-
Re: DatObjectDecoreator SQL Query Not working

18 September 2012 at 10:07pm
Hey
Thanks Simon_W, this sorted it, something for me to remember in future too
| 169 Views | ||
|
Page:
1
|
Go to Top |

