I had the same problem. My project is very old, and he tried to fix it quickly. So I just changed the code for Doctrine a bit, so I can use case when. This is my code for Doctrine 1.1.3.
Doctrine / Query.php, change the lines from 658 to 674:
if (count($terms) > 1 || $pos !== false) { if($terms[0]=='case') { $terms=explode(" as ", $reference); $expression = array_shift($terms); $alias = array_pop($terms); if ( ! $alias) { $alias = substr($expression, 0, $pos); } $componentAlias = $this->getExpressionOwner($expression); $tableAlias = $this->getTableAlias($componentAlias); $expression=str_replace($componentAlias, $tableAlias, $expression); $index=0; $sqlAlias = $tableAlias . '__' . $alias; } else { $expression = array_shift($terms); $alias = array_pop($terms); if ( ! $alias) { $alias = substr($expression, 0, $pos); } $componentAlias = $this->getExpressionOwner($expression); $expression = $this->parseClause($expression); $tableAlias = $this->getTableAlias($componentAlias); $index = count($this->_aggregateAliasMap); $sqlAlias = $this->_conn->quoteIdentifier($tableAlias . '__' . $index); } $this->_sqlParts['select'][] = $expression . ' AS ' . $sqlAlias;
This is not a big change, but it helped me ...
source share