2012-08-12 82 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