如何从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"
}
答案 0 :(得分:0)
行对象意味着是DbTable行结构的反射表示。能够从Row对象中排除字段是矛盾的行为。