Php Zend_Db_表-关联数组而不是对象

Php Zend_Db_表-关联数组而不是对象,php,mysql,zend-framework,Php,Mysql,Zend Framework,以下一行: $select = $table->select(); $select->where('approved = 1'); $result = $table->fetchRow($select); 返回一个对象。我想要的是得到一个关联数组 我知道Zend_Db有fetchAssoc()方法,但Zend_Db_表中也有类似的方法(我尝试了fetchAssoc(),但它不起作用,我在文档中没有找到任何东西) Zend\u Db\u Table\u行和Zend\u Db\u

以下一行:

$select = $table->select();
$select->where('approved = 1');
$result = $table->fetchRow($select);
返回一个对象。我想要的是得到一个关联数组

我知道Zend_Db有fetchAssoc()方法,但Zend_Db_表中也有类似的方法(我尝试了fetchAssoc(),但它不起作用,我在文档中没有找到任何东西)


Zend\u Db\u Table\u行
Zend\u Db\u Table\u行集
都有一个
toArray()
方法。行作为关联数组返回,行集作为关联数组的简单(有序)数组返回。

为了进一步说明Bill的答案,如果您希望行集作为关联数组(而不是有序数组)返回,唯一的选择似乎是Zend_Db(如您所述):

然后在代码中:

$this->some_table = new SomeTable();
//Get and print some row(s) 
$where = $this->some_table->getAdapter()->quoteInto('primarykey_name = ?', $primarykey_value);
print_r($this->somes_table->getAssoc($where));

//Get and print all rows 
print_r($this->areas_table->getAssoc());
$db     = $table->getAdapter();
$select = $table->select();
$select->where('approved = 1');
$result = $db->fetchAssoc($select);
Zend_Loader::loadClass('Zend_Db_Table');
class SomeTable extends Zend_Db_Table_Abstract{

protected $_name = 'sometable';

public function getAssoc($where = null, $order = null, $count = null, $offset = null){
    if (!($where instanceof Zend_Db_Table_Select)) {
        $select = $this->select();

        if ($where !== null) {
            $this->_where($select, $where);
        }

        if ($order !== null) {
            $this->_order($select, $order);
        }

        if ($count !== null || $offset !== null) {
            $select->limit($count, $offset);
        }

    } else {
        $select = $where;
    }   
    return $this->getAdapter()->fetchAssoc($select);        
}
}
$this->some_table = new SomeTable();
//Get and print some row(s) 
$where = $this->some_table->getAdapter()->quoteInto('primarykey_name = ?', $primarykey_value);
print_r($this->somes_table->getAssoc($where));

//Get and print all rows 
print_r($this->areas_table->getAssoc());