[英]Zend - Selecting a specific field
I'm trying to query a database to find the results of one specific field in a table. 我正在尝试查询数据库以查找表中一个特定字段的结果。 The following code, from all the reserach I've done, should return only the 'id_maquina' field but it's actually returning all fields.
从我完成的所有研究中,以下代码应仅返回“ 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);
I added the *array('t1.id_maquina')* to the from method to specify that as the field I want as instructed in a post here on stackoverflow but it's not working. 我在from方法中添加了* array('t1.id_maquina')*,以按照我在stackoverflow上的帖子中的指示将其指定为我想要的字段,但是它不起作用。 Anyone has any thoughts on what is wrong with this?
有人对此有何想法?
Which Zend version do you use? 您使用哪个Zend版本?
You select all Columns form the joined table, because '*' (all columns) is default for the join. 您选择联接表中的所有列,因为联接的默认值为“ *”(所有列)。
Try: 尝试:
$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.