ifnull

IFNULL in Symfony2 Doctrine query builder

雨燕双飞 提交于 2019-12-01 00:42:15
How is the IFNULL of SQL implemented in Symfony2 Doctrine Query Builder? Let's say I have this query: select * from ticket order by IFNULL(modified_date, '2000-01-01') DESC, created_date DESC I have this DQL: $this->qb->select("t, c.name") ->from("Ticket", "t"); $this->qb->orderBy("t.modifiedDate", "DESC"); $this->qb->addOrderBy("t.createdDate", "DESC"); Now how to add the IFNULL part? ArVan Ok, done some research and found that there is no such implementation. Googled a little more, and got that this kind of missing features can be added to Doctrine as own functions. Found this extension on

IFNULL in Symfony2 Doctrine query builder

我的梦境 提交于 2019-11-30 19:34:22
问题 How is the IFNULL of SQL implemented in Symfony2 Doctrine Query Builder? Let's say I have this query: select * from ticket order by IFNULL(modified_date, '2000-01-01') DESC, created_date DESC I have this DQL: $this->qb->select("t, c.name") ->from("Ticket", "t"); $this->qb->orderBy("t.modifiedDate", "DESC"); $this->qb->addOrderBy("t.createdDate", "DESC"); Now how to add the IFNULL part? 回答1: Ok, done some research and found that there is no such implementation. Googled a little more, and got

mysql IFNULL ELSE

荒凉一梦 提交于 2019-11-30 00:20:19
I have a select statement where I want to make select conditional like this IFNULL(field_a,field_a,feild_b) so that it checks field a if a is null then the select would be field b is that possible ? OMG Ponies Use COALESCE : SELECT COALESCE(field_a, field_b) COALESCE is an ANSI standard function that returns the first non-null value from the list of columns specified, processing the columns from left to right. So in the example, if field_a is null, field_b value will be displayed. However, this function will return NULL if there is no non-null value from the columns specified. It's supported