0

I can not get the result of such a request:

$performance = DB::select("SELECT ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60) FROM tickets WHERE id = ?", [$id]);

the result comes in the form of an array:

array:1 [
 0 => {#1385 
  +"ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60)": "299"
 }
]

1 Answer 1

2

Thats becouse your not included get() in end of your code. Replace this:

$performance = DB::select("SELECT ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60) FROM tickets WHERE id = ?", [$id])->get();

with this:

$performance = DB::select("SELECT ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60) FROM tickets WHERE id = ?", [$id]);
Sign up to request clarification or add additional context in comments.

5 Comments

now wrote the request correctly $performance = DB::table('tickets')->selectRaw('ROUND(TIME_TO_SEC(timediff(NOW(), date_finish))/60)')->where('id', $id)->get(); but still the result is output as an array
<input type="hidden" name="performance" value="{{ $performance }}">
May I ask what your query does?
this query gets the difference between the dates of the given string
Did you tried whereBetween? Look at this link too stackoverflow.com/a/33361741/13661216

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.