简体   繁体   中英

drupal 7 $query->where and DATE_FORMAT not recognized

I have implement a function views_query_alter. I want to add a where clause. I try with : $query->add_where(0, "DATE_FORMAT(myfieldname, '%Y-%m-%d')", "DATE_FORMAT(now(), '%Y-%m-%d')", '>');

I also try with condition. The result printed sql is the same from both cases and is DATE_FORMATmyfieldnameYmd. Is there any way to escaped a DATE_FORMAT or anything to succesfully recognized DATE_FORMAT function into where clause?

Thank you in advance

不知道您是否找到了解决方案,但以下对我有用

$query->add_where_expression(0, "DATE_FORMAT(STR_TO_DATE(myfieldname.value, '%Y-%m-%d'), '%Y-%m') > 'value'");

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