->sql not working when using dynamic variable
->sql not working when using dynamic variable
Restful Web Services
Posts: 202Questions: 49Answers: 2
Why does this work?
$iChaletId = '216';
$rawquery = "SELECT t_owneraccount.iChaletId, SUM(t_owneraccount.fTotal) AS fTotal_total FROM t_owneraccount WHERE t_owneraccount.iChaletId = $iChaletId GROUP BY t_owneraccount.iChaletId";
// select data
$fTotal = array();
$fTotal = $db
->sql( $rawquery )
->fetchAll();
return $fTotal;
But this does not?
$iChaletId = $data['t_chalet.iChaletId'];
$rawquery = "SELECT t_owneraccount.iChaletId, SUM(t_owneraccount.fTotal) AS fTotal_total FROM t_owneraccount WHERE t_owneraccount.iChaletId = $iChaletId GROUP BY t_owneraccount.iChaletId";
// select data
$fTotal = array();
$fTotal = $db
->sql( $rawquery )
->fetchAll();
return $fTotal;
If I echo $data['t_chalet.iChaletId']
it is the correct value.
This also works,
$iChaletId = $data['t_chalet.iChaletId'];
$rawquery = "SELECT t_owneraccount.iChaletId, SUM(t_owneraccount.fTotal) AS fTotal_total FROM t_owneraccount GROUP BY t_owneraccount.iChaletId";
// select data
$fTotal = array();
$fTotal = $db
->sql( $rawquery )
->fetchAll();
return $fTotal;
I cannot understand it?
This discussion has been closed.
Answers
Can you show me the result of:
if you insert those two lines at line 4 in your above example (that doesn't work)?
Thanks,
Allan
Hi Allan,
I am pretty sure now that is is something to do with the SUM return an empty or
null
value.If I try:
At line 4 as you suggested nothing happens, the XHR request just stays on pending. I don't get an error back, I get no response at all.
Chris
Odd - have a look at the server's error logs. They might show why it is bombing.
Allan