2012-11-08 47 views
2

如何從findManyToManyRowset()方法結果中排除列?findManyToManyRowset排除列

$servers = $this->findManyToManyRowset(
       'Serverlog_Model_DbTable_Computer', 
       'Serverlog_Model_DbTable_Server'); 

$服務器 - >指定者()給我:

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繼承,但一切都沒有改變。

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']); 
} 
} 

我想從$服務器 - >指定者()結果:

object(Serverlog_Model_Rowset_Computer)#458 (10) { 
["_data":protected] => array(5) { 
[0] => array(27) { 
    ["id"] => int(462) 
    ["name"] => string(10) "test" 
} 

回答

0

行對象是意味着是DBTABLE行結構的reflectional表示。能夠從Row對象中排除字段是矛盾的行爲。