dg / dibi

Dibi - smart database abstraction layer
https://dibiphp.com
Other
487 stars 135 forks source link

expression in columns array not working #369

Open SukPavel opened 4 years ago

SukPavel commented 4 years ago

Version: 4.1.3

dibi::expression in conjunction with %n modifier and alias not working

$cols = [
    'name' => firstname,
    'surname' => 'lastname',
    dibi::expression("DATE_FORMAT(date_created, '%Y/%m/%d %k:%i')") => 'date_created'
];

used as: dibi::fetchAll('SELECT %n FROM users', $cols);

will result in SELECT name AS firstname, surname AS lastname FROM users

dg commented 4 years ago

I don't understand what you mean.

SukPavel commented 4 years ago

OK.

Is it possible to define selected columns by array (using %n modifier) where column names are not only names but expressions like DATE_FORMAT, IF(), atc?

According to docs this should be possible, but final query does not contain columns that are defined as expressions.