2012-08-12 78 views
1

我想使用Zend框架構建SQL查詢。這裏是我的SQL查詢語句:使用zend框架獲取來自多個表的數據

SELECT of.order_Id, of.subtotal, of.status, c.name 
    FROM order_form of, customer c 
    WHERE c.customer_Id = of.customer_Id 

然而,當我試圖實現它在Zend框架,將顯示一條錯誤消息。這是我使用Zend Framework的查詢語句。

$query = $db->select() 
      ->from(array('c' => 'customer'), 'name') 
      ->where('c.customer_Id = ?', $customer_Id) 
      ->join('order_form', 'order_form.customer_Id = customer.customer_Id', array('order_Id', 'subtotal', 'status')) 
      ->order("order_form.order_Id ASC"); 
+0

什麼是錯誤 – 2012-08-14 05:48:05

+0

嗨維傑,問題解決了,對不便引起的不便引起的 – Dale 2012-08-18 04:56:01

回答

0

我的部分有錯誤。只需將join條款

$query = $db->select() 
      ->from(array('c' => 'customer'), 'name') 
      ->where('c.customer_Id = ?', $customer_Id) 
      ->join('order_form', 'order_form.customer_Id = c.customer_Id', array('order_Id', 'subtotal', 'status')) 
      ->order("order_form.order_Id ASC"); 

抱歉造成的任何不便在改變customer.customer_Idc.customer_Id