【问题标题】:Magento, modify Zend_Db_Select SET group_concat_max_lenMagento,修改 Zend_Db_Select SET group_concat_max_len
【发布时间】:2014-10-12 21:03:59
【问题描述】:

我正在尝试更新/添加一个设置到 Magento getSelect() 查询语句,但我不太确定在哪里添加它。

我需要确保 SET group_concat_max_len = 32768 用于以下查询:

$this->getSelect()->joinLeft(array('order_item_tbl'=>$this->getTable('sales/order_item')),
                    'order_item_tbl.order_id = main_table.entity_id',
                    array(
                        'product_names' => new Zend_Db_Expr('GROUP_CONCAT(order_item_tbl.`name` SEPARATOR \'\n\')'),
                        'skus' => new Zend_Db_Expr('GROUP_CONCAT(order_item_tbl.`sku` SEPARATOR \'\n\')'),
                        'product_ids' => new Zend_Db_Expr('GROUP_CONCAT(order_item_tbl.`product_id` SEPARATOR \'\n\')'),
                        'product_options' => new Zend_Db_Expr('GROUP_CONCAT(order_item_tbl.`product_options` SEPARATOR \'^\')'),
                        'total_qty_refunded' => new Zend_Db_Expr('SUM(order_item_tbl.`qty_refunded`)'),
                        'total_qty_invoiced' => new Zend_Db_Expr('SUM(order_item_tbl.`qty_invoiced`)')
                    ))
                    ->where('order_item_tbl.`parent_item_id` IS NULL');

【问题讨论】:

    标签: mysql magento zend-db magento-1.8


    【解决方案1】:

    我想这应该可以,从核心资源获取连接作为通常用于插入/更新目的的写入模式,但您也可以运行查询

    $res=Mage::getSingleton('core/resource');
    
    $connection = $res->getConnection('core_write');
    
    $connection->query('SET group_concat_max_len = 32768');
    

    Raw queries in mangento

    【讨论】:

    • 只需将此代码放在我的 getSelect 查询之前?
    • 你真的是万王之王。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-30
    • 1970-01-01
    相关资源
    最近更新 更多