Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL statement based on $curr_time->format('Y-m-d H:i')

Tags:

sql

php

mysql

Why this code...

$curr_time = new DateTime();
$query_inprocess = "UPDATE `MyTable` 
                    SET inprocess=1 
                    WHERE startTime <= '" .$curr_time->format('Y-m-d H:i') . "'";

...results in incorrect SQL query, in which the statement after < is ignored?

UPDATE `MyTable` SET inprocess=1 WHERE startTime <
like image 486
You Kuper Avatar asked Nov 12 '22 23:11

You Kuper


1 Answers

Find the below one :

"UPDATE `MyTable` SET inprocess=1 WHERE startTime <= now()"

It may help you to get the exact result which one you need.

like image 95
John Peter Avatar answered Nov 15 '22 13:11

John Peter