Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbboke.com/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php:409) in /www/wwwroot/sbboke.com/wp-content/themes/pacify/content-single.php on line 5

Magento2 与addFieldToSelect相比,addExpressionFieldToSelect有什么用?

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.

版权属于: sbboke版权所有。

转载时必须以链接形式注明作者和原始出处及本声明。

张贴在magento2教程标签:

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论