繁体   English   中英

Zend-选择一个特定的领域

[英]Zend - Selecting a specific field

我正在尝试查询数据库以查找表中一个特定字段的结果。 从我完成的所有研究中,以下代码应仅返回“ id_maquina”字段,但实际上返回的是所有字段。

$hist_select=$historico->select()
    ->setIntegrityCheck(false)
    ->from(array('t1'=>'maquina_cafe'),array('t1.id_maquina'))
    ->joinLeft(array('t2'=>'maquinas'),'t1.id_maquina=t2.ID')
    ->where('t1.username = ?',$identity);

我在from方法中添加了* array('t1.id_maquina')*,以按照我在stackoverflow上的帖子中的指示将其指定为我想要的字段,但是它不起作用。 有人对此有何想法?

您使用哪个Zend版本?

您选择联接表中的所有列,因为联接的默认值为“ *”(所有列)。

尝试:

$hist_select=$historico->select()
                      ->setIntegrityCheck(false)
                      ->from(array('t1'=>'maquina_cafe'),array('t1.id_maquina'))
                      ->joinLeft(array('t2'=>'maquinas'),'t1.id_maquina=t2.ID', array())
                      ->where('t1.username = ?',$identity);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM