Magento,修改Zend_Db_Select SET group_concat_max_len

时间:2014-08-19 16:52:03

标签: mysql magento zend-db magento-1.8

我正在尝试更新/添加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');

1 个答案:

答案 0 :(得分:1)

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

$res=Mage::getSingleton('core/resource');

$connection = $res->getConnection('core_write');

$connection->query('SET group_concat_max_len = 32768');

Raw queries in mangento