fluentpdo
fluentpdo copied to clipboard
Error with %d format symbol inside select clause
$dbh = new \PDO(sprintf("mysql:host=%s;port=%s;dbname=%s", 'localhost', 3306, 'database'), 'root', 'password');
$query = new \Envms\FluentPDO\Query($dbh);
$query = $query;
$query = $query
->from("articles")
->select("
*,
DATE_FORMAT(cdate, '%H:%i %d.%m.%Y') AS cdate2,
DATE_FORMAT(cdate, '%d.%m.%Y') AS cdate3,
", true
);
var_dump($query->getQuery());
Result is:
SELECT
*,
DATE_FORMAT(cdate, '%H.%i %m.%Y') AS cdate2,
DATE_FORMAT(cdate, %m.%Y') AS cdate3,
FROM articles
LEFT JOIN H ON H.articles_id = articles.id
LEFT JOIN d ON d.id = articles.d_id
WTF? O.O
([^[:space:]()]+[.:])[\p{L}\p{N}\p{Pc}\p{Pd}\p{Pf}\p{Pi}]*
error somewhere here...
Thanks for submitting @KarelWintersky, I had a chance to look at this now. It's very likely that you're using a dot .
as the time separator. There are a couple ways to solve what you're attempting:
- Use the
Literal
class (eg.new Literal('%H.%i')
) built into Fluent to prevent automatically attempting joins on those values. - Use another separator other than
.
and:
.
@cbornhoft is any way to remove :
from params (named placeholder) and insert it automatically?