2011-01-13 3 views
7

는 마 젠토는, 예를 들어 거대한 물체를 인쇄하는 대신 문자열 형식의 결과 쿼리를 표시하는 방법이 있나요Magento SQL 쿼리를 문자열로 어떻게 표시합니까?

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

처럼 자사의 SQL 쿼리를 구성한다

답변

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

echo $select; 
+9

프로그래머 여러분께서는 선택 객체가 echo와 함께 사용될 때 문자열로 캐스팅되는 것을 보게됩니다. (string) $ select 또는 $ seletct -> __ toString()을 사용하면 동일한 결과가 생성됩니다. –

4

내가 관심있는 사람들을 위해 거의 -> __ toString()을 사용해야합니다.

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

에코는 그것이 자신의 toString 메소드 –

+1

의가로 충분히 그리고 가끔은 자동으로'__toString' 방법을 실행하는 데 캐스팅해야합니다. 'echo (string) $ this-> getSelect ... '와 같은 것. – clockworkgeek

관련 문제