php - ZF2 查询结果不正确

标签 php mysql zend-framework2

我在模型中有一个查询:

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。我的查询有什么问题??谢谢

最佳答案

请修改您的查询:

$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');

关于php - ZF2 查询结果不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36416652/

相关文章:

php - 带 % 和 concat 的 PDO 准备语句

php - yii mssql 查询不工作

mysql - 请解决错误

mysql - windows 2008压缩Mysql数据驱动器的性能优势

zend-framework - 在扩展的 zend 表单类中使用注释生成器

javascript - 如何将 AJAX 变量传递给 PHP

php - array_unique 用于数组内的数组

php - 多个 MySQL 查询以及如何使我的脚本运行得更快

html - 如何自定义我网站的主题取决于用户

php - 在 Zend Framework 2 (ZF2) 中创建新 Controller 的问题