在addExpressionFieldToSelect()
中 ,您可以传递Zend_Db_Expr
带有任意SQL表达式的实例。
因此,举例来说,这是可以实现的addExpressionFieldToSelect()
,但不能实现addFieldToSelect()
:
$collection->addExpressionFieldToSelect(
'name_in_upper_case',
new Zend_Db_Expr('UPPER(name)'),
[]
);
并导致SQL查询
SELECT UPPER(name) as name_in_upper_case FROM ...
The placeholders for fieldnames are just syntactic sugar on top.