jonny
(Jonny)
1
Hi
How would I use a built in SQL function with Querybuilder? I am trying to use IFNULL within a select statement
My code is:
$q = new Query;
$q->select('score');
// I tried $q->select('IFNULL(score,0)');
But that got parsed as SELECT IFNULL(score, 0)
Thanks
samdark
(Alexander Makarov)
2
jonny
(Jonny)
3
Hi alex
I tried:
$expression = new Expression('IFNULL(score, 0)');
$query->select($expression);
But it still got executed as
SELECT IFNULL(score, `0)`
What did I do wrong?
Pasman
(Pasman P)
4
try it:
$q->select(['IFNULL(score,0)']);
jonny
(Jonny)
5
No that didn’t work either
Pasman
(Pasman P)
6
What is error message ?
This is working with postgres driver.
You may use selectOptions property too.
jonny
(Jonny)
7
My mistake, it does work. I was tired last night.
Jonathon