0

I'm trying to change a sorting by date of stores localized in my map (WP plugin: store-locator-le) with PHP and MySql. I insert the date in Phone field, so before I have to change the field in date. can you help me?

 $this->dbQuery = apply_filters('slp_mysql_search_query',
        "SELECT *,STR_TO_DATE(sl_phone, '%d-%m-%Y') as date ".
        "FROM store_locator ".
        'ORDER BY date ASC'
        );

if I write the sql code in mysql phpmyadmin, it works!

  • `STR_TO_DATE(sl_phone, "%d-%m-%Y") ` should probably be `STR_TO_DATE(sl_phone, \"%d-%m-%Y\") ` and you may want to [give this a read](http://stackoverflow.com/questions/3446216/what-is-the-difference-between-single-quoted-and-double-quoted-strings-in-php) – castis Jul 08 '15 at 21:18
  • I was wrong to write. now i write the right code, but the stores are not sorted – Marco Santini Jul 08 '15 at 21:27
  • If it works in phpmyadmin, the query will have the same result in php. The problems is probably how you process it. – DocRattie Jul 08 '15 at 21:43
  • @DocRattie i think that %d %m %Y are caught from php and not from sql – Marco Santini Jul 08 '15 at 22:05
  • They are just normal sign in a string. why should they be caught? And did you try to echo the string in php again? – DocRattie Jul 09 '15 at 07:11

1 Answers1

0

The problem is the apply_filter function. Using %%d-%%m-%%Y the query