Laravel query not binding values correctly -


my query returning wrong results , think because final parameter (minutes) not being binded query. when querylog seems fine wrong results being returned. if putthe minutes parameter directly query returns right results expected value needs variable.

to explain query counting records until total minutes hit set number, in example im using 500.

this query works , returns results expected:

db::select('select null session_total_charges, null call_date, null inbound_duration, null total   dual  @total := 0   union select session_total_charges, call_date, inbound_duration,  @total := @total + inbound_duration total  (select * records  order call_date) c calling_user =:user , call_date :date , outbound_zone_id in ("ukx","ukm","uklr","uknr") , @total < 500', ["user"=>$user, "date"=>$date]); 

this query not work , returns 1 row

db::select('select null session_total_charges, null call_date, null inbound_duration, null total   dual  @total := 0   union select session_total_charges, call_date, inbound_duration,  @total := @total + inbound_duration total  (select * records  order call_date) c calling_user =:user , call_date :date , outbound_zone_id in ("ukx","ukm","uklr","uknr") , @total < :minutes', ["user"=>$user, "date"=>$date, "minutes"=>$minutes]);   [query] => select null session_total_charges, null call_date, null inbound_duration, null total       dual      @total := 0      union     select session_total_charges, call_date, inbound_duration,  @total := @total +  inbound_duration total      (select * records  order call_date) c calling_user =:user , call_date :date , outbound_zone_id in ("ukx","ukm","uklr","uknr") , @total < :minutes               [bindings] => array                   (                      [user] => t-m000005251-009                      [minutes] => 500                      [date] => 2016-12-%%                    )    //result using bindings (only 1 row returned)      [0] => stdclass object             (                 [session_total_charges] => 0.014125                 [call_date] => 2016-12-01 09:12:39                 [inbound_duration] => 113                 [total] => 113             )  //result values inserted directly query(correct result returned)       [0] => stdclass object             (                 [session_total_charges] => 0.014125                 [call_date] => 2016-12-01 09:12:39                 [inbound_duration] => 113                 [total] => 113             )          [1] => stdclass object             (                 [session_total_charges] => 0.04733333                 [call_date] => 2016-12-01 09:18:16                 [inbound_duration] => 142                 [total] => 255             )          [2] => stdclass object             (                 [session_total_charges] => 0.03866667                 [call_date] => 2016-12-01 09:22:21                 [inbound_duration] => 116                 [total] => 371             )          [3] => stdclass object             (                 [session_total_charges] => 0.012625                 [call_date] => 2016-12-01 09:29:24                 [inbound_duration] => 101                 [total] => 472             )          [4] => stdclass object             (                 [session_total_charges] => 0.0505                 [call_date] => 2016-12-01 12:03:16                 [inbound_duration] => 404                 [total] => 876             ) 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -