I have some code as follows:
$query = <<<QUERY
SELECT
*
FROM
names
WHERE
create_date > date('Y-m-d H:i:s');
QUERY
How can I put the date('Y-m-d H:i:s')
in there without breaking out of the <<<
statement?
I have some code as follows:
$query = <<<QUERY
SELECT
*
FROM
names
WHERE
create_date > date('Y-m-d H:i:s');
QUERY
How can I put the date('Y-m-d H:i:s')
in there without breaking out of the <<<
statement?
You could store that piece of code in a variable and use substitution.
$now = date('Y-m-d H:i:s');
$query = <<<QUERY
SELECT
*
FROM
names
WHERE
create_date > $now;
QUERY;
(Example: http://www.ideone.com/pKSVF)
$date = date('Y-m-d H:i:s');
$query = <<<QUERY
SELECT
*
FROM
names
WHERE
create_date > $date
QUERY