开发者

how to execute the query that include date function(MySQL)

I got a query including two variable parameters. It cannot be executed successfully. Anyone help me to have a look. thanks

$queryUpdateScreeningMai开发者_高级运维leddate = "UPDATE screening
     SET maileddate = {date('Y-m-d', strtotime($mailed_date[$screeningId]))}
      WHERE user_id IN (  
                     select s.id
                     from (
                         SELECT users.id
                         FROM users
                         INNER JOIN screening ON 
                         users.id = screening .user_id
                         AND screening.id = {$screeningId}
                          ) as s)
       AND date BETWEEN '2011-05-15' AND '2011-11-15'";

   $_db->executeQuery($queryUpdateScreeningMaileddate); 


Curly brace {} syntax only works for variables, it doesn't work for function calls. You will have to break the string up like this:

$queryUpdateScreeningMaileddate = "UPDATE screening
     SET maileddate = '".date('Y-m-d', strtotime($mailed_date[$screeningId]))."'
      WHERE user_id IN (  
                     select s.id
                     from (
                         SELECT users.id
                         FROM users
                         INNER JOIN screening ON 
                         users.id = screening .user_id
                         AND screening.id = {$screeningId}
                          ) as s)
       AND date BETWEEN '2011-05-15' AND '2011-11-15'";

   $_db->executeQuery($queryUpdateScreeningMaileddate); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜