如何从 findManyToManyRowset() 方法结果中排除列?
$servers = $this->findManyToManyRowset(
'Serverlog_Model_DbTable_Computer',
'Serverlog_Model_DbTable_Server');
$servers->toArray() 给了我:
object(Serverlog_Model_Rowset_Computer)#458 (10) {
["_data":protected] => array(5) {
[0] => array(27) {
["id"] => int(462)
["name"] => string(10) "test"
["key"] => string(0) ""
["keyboard"] => int(1)
["mouse"] => int(0)
["serial_nr"] => string(10) "test"
["status"] => int(1)
}
我试图重载继承自 Zend_Db_Table_Rowset_Abstract 和 Zend_Db_Table_Row_Abstract 的方法 toArray(),但没有任何改变。
class Serverlog_Model_DbTable_Computer extends My_DbTable_Model {
protected $_name = 'computers';
protected $_dependentTables = array('Serverlog_Model_DbTable_Server');
protected $_rowClass = 'Serverlog_Model_Row_Computer';
protected $_rowsetClass = 'Serverlog_Model_Rowset_Computer';
class Serverlog_Model_Rowset_Computer extends Zend_Db_Table_Rowset_Abstract {
public function toArray() {
foreach ($this->_rows as $i => $row) {
$this->_data[$i] = array($row->_data['id'] => $row->_data['name']);
}
return $this->_data;
}
class Serverlog_Model_Row_Computer extends Zend_Db_Table_Row_Abstract {
public function toArray() {
return array($this->_data['id'] => $this->_data['name']);
}
}
我想从 $servers->toArray() 得到结果:
object(Serverlog_Model_Rowset_Computer)#458 (10) {
["_data":protected] => array(5) {
[0] => array(27) {
["id"] => int(462)
["name"] => string(10) "test"
}