database
database copied to clipboard
Unable to use lowercase SQL params
NTDB is escaping lowercase, so i am unable to use expressions like this:
$selection->where(["DATE_FORMAT(eventStart,'%Y-%m-%d'" => '2017-01-26'])
It always escaped (even when i use SQLLiteral), and resulting SQL looks like this:
(DATE_FORMAT(`eventStart`,'%Y-%`m`-%`d`' = '2017-01-26)
Notice that Y
is not escaped, while the other two letters are.
Of what i found, escaping happens here: https://github.com/nette/database/blob/master/src/Database/Table/SqlBuilder.php#L759
For this moment you can write like:
dump($selection->where('DATE_FORMAT(registration_date, ?) = ?', '%Y-%m-%d', '2017-01-26')->fetch());
// or if you need this format YYYY-MM-DD
dump($selection->where('DATE(registration_date)', '2017-01-26')->fetch());
Oh, thank you, it works. I guess it is solved then?
It would just be nice if documentation had this info.