I'm trying to make a select statement using PDO and MySql. I have the following code:
$this->bind[':created'] = "'" . (new DateTime('First day of this month'))->format('Y-m-d') . "' AND '" . date('Y-m-d') . "'";
$this->where[] = "created BETWEEM :created";
As you can see, i'm putting a quote character wrapping the date, following MySql documentation but PHP is escaping it and i'm getting an error.
'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'created BETWEEN '\'2015-07-01\' AND \'2015-07-24\'' '
So, how can i use a range date with PDO::bindValue()?
Being more specific, i want to get this result:
SELECT * FROM table WHERE created BETWEEN '2015-07-01' AND '2015-07-24'
rather than:
SELECT * FROM table WHERE created BETWEEN '\'2015-07-01\' AND '\2015-07-24\''
Thank you.