gpt4 book ai didi

php - 加入到creditmemo_flat_table

转载 作者:行者123 更新时间:2023-11-29 13:26:25 24 4
gpt4 key购买 nike

当加入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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com