Hi,
This is the non-working code:
- Code: Select all
$sql = "SELECT sum(QUANTITAT) FROM contractes_detall WHERE contractes_detall.IDCONTRACTE=".$record->val('IDCONTRACTE')." AND contractes_detall.DATA<='".date('Y-m-d G:i:s', strtotime($record->strval('DATA')))."'";
$res = mysql_query($sql);
$total = number_format(mysql_result($res,0),2,',','.');
And this the working code:
- Code: Select all
$sql = "SELECT DATA FROM contractes_detall WHERE ID=".$record->val('ID');
$data = mysql_query($sql);
$sql = "SELECT sum(QUANTITAT) FROM contractes_detall WHERE contractes_detall.IDCONTRACTE=".$record->val('IDCONTRACTE')." AND contractes_detall.DATA<='".date('Y-m-d G:i:s', strtotime(mysql_result($data,0)))."'";
$res = mysql_query($sql);
$total = number_format(mysql_result($res,0),2,',','.');
So, it is getting different time (daylight savings applied in mysql select but not in $record->strval) when I use first code, where the data comparison is made against strtotime($record->strval('DATA')), while in the second code (the working one), I have to query mysql for current date (not using xataface api) and then use it inside my mysql query. This, of course, gets the same times from timestamp.
I'm pretty sure that my working code is not the ideal approach to what I'm trying to do. How can it be done using only xataface api?
Thanks.