gpt4 book ai didi

mysql - Magento/Zend 框架 : Custom Join Statement : ERROR : Can't prepare expression when tableName is instance of Zend_Db_Expr

转载 作者:行者123 更新时间:2023-11-30 21:49:47 24 4
gpt4 key购买 nike

在 Magento v1 中,我尝试添加一个自定义的内部连接,如下所示:

INNER JOIN (SELECT entity_id, LEFT(sku, 11) AS lwin11 FROM catalog_product_flat_1) AS test_lwin11 ON test_lwin11.entity_id = e.entity_id

我尝试使用 新的 Zend_Db_Expr

$select->joinInner(['test_lwin11' => new Zend_Db_Expr('(SELECT entity_id, LEFT(sku, 11) AS lwin11 FROM catalog_product_flat_1)')], 'test_lwin11.entity_id = e.entity_id');

但这会抛出以下错误:

当 tableName 是 Zend_Db_Expr 的实例时无法准备表达式

有什么想法吗?

最佳答案

你可以试试:

$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$tlw11 = $connection ->select()->from('catalog_product_flat_1', ['entity_id', 'lwin11' => 'LEFT(sku, 11)']);

然后

->join(['test_lwin11' => $tlw11], 'test_lwin11.entity_id = e.entity_id')

关于mysql - Magento/Zend 框架 : Custom Join Statement : ERROR : Can't prepare expression when tableName is instance of Zend_Db_Expr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47790874/

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