作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当加入creditmemo_flat_table
时
$collection = Mage::getResourceModel('sales/order_creditmemo_grid_collection');
$collection->getSelect()
->join(
array('creditmemo_table' => 'sales_flat_creditmemo'),
'main_table.entity_id = creditmemo_table.entity_id',
array('creditmemo_table.gift_cards_amount')
);
当 gift_cards_amount
存在时,我得到正确的值,当它不存在时,我得到 null 。但对于网格,我需要零而不是null。有人知道如何解决这个问题吗?
最佳答案
SQL select语法提供了IFNULL方法,这里可以直接使用。
这就是您应该修改 select 语句的方式
$collection->getSelect()
->join(
array('creditmemo_table' => 'sales_flat_creditmemo'),
'main_table.entity_id = creditmemo_table.entity_id',
array('IFNULL(creditmemo_table.gift_cards_amount,0) as gift_cards_amount')
);
关于php - 加入到creditmemo_flat_table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20067541/
我是一名优秀的程序员,十分优秀!