开发者

How do you display a Magento sql query as a string?

开发者 https://www.devze.com 2023-02-03 20:31 出处:网络
Magento constructs its SQL queries like $this->getSelect()->joinInner( array(\'sbao\' => $this->getTable(\'sales/billing_agreement_order\')),

Magento constructs its SQL queries like

 $this->getSelect()->joinInner(
        array('sbao' => $this->getTable('sales/billing_agreement_order')),
        'main_table.entity_id = sbao.order_id',
        array()
    )

Is there a way to display the resulting query in a string format rather than printing out the huge object e.g.

echo $this->getSelect()->joinInner(
        array('sbao' => $this->getTable('sales/billing_agreement_order')),
        'main_table.entity_id = sbao.order_id',
        array()
    )->开发者_JAVA技巧;toString();


$select = $this->getSelect()->joinInner(
        array('sbao' => $this->getTable('sales/billing_agreement_order')),
        'main_table.entity_id = sbao.order_id',
        array()
    );

echo $select;


I nearly had it for those interested you need to use ->__toString() e.g.

echo $this->getSelect()->joinInner(
    array('sbao' => $this->getTable('sales/billing_agreement_order')),
    'main_table.entity_id = sbao.order_id',
    array()
)->__toString()
0

精彩评论

暂无评论...
验证码 换一张
取 消