在zend框架模型中选择特定列

时间:2013-05-20 09:58:04

标签: zend-framework

我是zend框架中的新手。下面是我在zend模型中的sql查询

$row = $select_company_table->fetchAll($select_company_table->select()->where('manage=1 and deleteOption=0')->order('id DESC'));

基本上它会获取表中的所有列。 我想只选择2列,即id和status,但我不知道语法。

1 个答案:

答案 0 :(得分:0)

使用以下代码:

$select = $this->select()
               ->from(array('company_table'),array("id","status"))
                ->where('manage = ?','1') 
                ->where('deleteOption = ?','0')
                ->order('id DESC');
$row = $this->fetchAll($select);

<强>编辑:

$select = $this->select()
               ->from(array('cwi_company'),array("*"))
                ->where('manage = ?','1') 
                ->where('deleteOption = ?','0')
                ->where('passwordStatus = ?','1')
                ->where('organizationuserid IN (SELECT userId FROM cwi_passtable WHERE passwordAciveStatus =1)');