SilverStripe 2.4.7
Hi
I've managed to confuse myself utterly so I hope I make sense.
Basically I was following this approach and that went fine for the most part.
My problem is that I need to pass the value of $output to the QRData variable so I can output it in a template but since it's an array I'm having trouble. I'm sure it's something obvious but I've spent hours trying to figure it out.
Here's my code
protected $QRData = false;
public function retrieveQR() {
$var = Director::urlParam('ID');
if(preg_match('/[0-9]+/', $var)){
$sqlQuery = new SQLQuery();
$sqlQuery->select = array(
'QRCode AS offerCode',
'QRCodeImage AS QR'
);
$sqlQuery->from = array("QRCode");
$sqlQuery->where = array("OfferID = '" . $var . "'" AND "Status = 0");
$rawSQL = $sqlQuery->sql();
$result = $sqlQuery->execute();
$output = array($result->first());
Debug::Show($output);
$QR = $output;
$this->QRData = $QR;
return array();
}
else{ return $this->httpError(404, 'Not a valid ID');}
}
public function getQRData() {
return $this->QRData;
}