2016-04-05 78 views
1

我在模型中有一个查询:不正确的查询结果ZF2

public function loadPerform(){ 
    $select = $this->select() 
       ->from(array('p' => $this->_tables['performance'])) 
       ->join(array('phc' => $this->_tables['perf_has_component']), 'phc.performance_id=p.performance_id', array('*'), 'left'); 
    //echo str_replace('"','',$select->getSqlString())."<br />"; 
    return $this->fetchAll($select); 
} 

结果是:

Array([0]=>Array(
[performance_id]=> 
[title]=>Performance11 
[description]=>haha 
[create_dtm]=>2016-04-0500: 14: 54 
[create_by]=>90141063 
[phc_id]=> 
[last_update_dtm]=> 
[update_by]=> 
)) 

它的工作原理,但它并没有显示出结果performance_id。我的查询出了什么问题?由于

回答

0

请修改查询:

$select = $this->select() 
       ->from(array('p' => $this->_tables['performance']),array('performance_id')) 
       ->join(array('phc' => $this->_tables['perf_has_component']), 'phc.performance_id=p.performance_id', array('*'), 'left'); 
+0

能否请你加上为什么会工作,为什么在问题的代码不会得到预期的结果一些解释。 – Wilt

+0

请参阅此页:http://framework.zend.com/manual/current/en/modules/zend.db.sql.html –