简体   繁体   中英

How to escape the \ in mysql query

$query1 = "UPDATE {$this->_vdmfInstance->sqltable('mod_calendar_repetitions')} set start=(DATE_FORMAT(CONCAT(date(start),'',DATE_FORMAT(".$from->format('Y-m-d H:i:s').",'%H.%i.%S')),'%Y-%m-%d %H:%i:%S') ), 
            end = (DATE_FORMAT(CONCAT(date(end),'',DATE_FORMAT(".$till->format('Y-m-d H:i:s').",'%H.%i.%S')),'%Y-%m-%d %H:%i:%S')) where event_id =".$repId;

This is my actual output from php and how to remove the escape strings ().

'UPDATE `mod_calendar_repetitions` set start=(DATE_FORMAT(CONCAT(date(start),\'-\',DATE_FORMAT(2015-09-14 15:00:00,\'%H.%i.%S\')),\'%Y-%m-%d %H:%i:%S\') ), 
            end = (DATE_FORMAT(CONCAT(date(end),\'\',DATE_FORMAT(2015-09-14 16:15:00,\'%H.%i.%S\')),\'%Y-%m-%d %H:%i:%S\')) where event_id =380;'

Need to mention $from and $till in between the single quotes.

$query1 = "UPDATE {$this->_vdmfInstance->sqltable('mod_calendar_repetitions')} set start=(DATE_FORMAT(CONCAT(date(start),'',DATE_FORMAT('".$from->format('Y-m-d H:i:s')."','%H.%i.%S')),'%Y-%m-%d %H:%i:%S') ),
end = (DATE_FORMAT(CONCAT(date(end),'',DATE_FORMAT('".$till->format('Y-m-d H:i:s')."','%H.%i.%S')),'%Y-%m-%d %H:%i:%S')) where event_id =".$repId;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM