Hello,

I have had to kind of hack something together.  Well let me put it this way,
if feels like a hack.  I am grabbing a selection from a db using a join.



$db = $table->getAdapter();
$select = $db->select()
        ->from( array( 'l' => 'log_email' ), array( 'l.Recipients', 'l.Sender',
'l.Subject', 'l.Date', 'COUNT(s.ID) as Source', 'COUNT(d.ID) as
Destination') )
        ->joinLeft( array( 's' => 'associations' ), 's.SourceID = l.LoggerID' )
        ->joinLeft( array( 'd' => 'associations' ), 'd.DestinationID = 
l.LoggerID'
)
        ->where('l.Recipients LIKE ?', '%' . $this->_getParam('Recipient') . 
'%')
        ->where('l.Sender LIKE ?'    , '%' . $this->_getParam('Sender') . '%' )
        ->where('l.Subject LIKE ?'   , '%' . $this->_getParam('Subject') . '%' 
);


Now $table is an instance of Zend_Db_Table_Abstract that is looking at the
log_email table (LogEmail), but because I want to join in the two counters I
have had to use the DB adapter.


My problem was that this just returns me an array of results and in my
LogEmailRow class (the row class of LogEmail) I need to process some data in
one of the columns so I needed force the results into the relevant
structure.  Ass demonstrated below.



$stmt = $select->query();
$dbRowSet = $stmt->fetchAll();
                                
$rowSet = new Zend_Db_Table_Rowset( array(
        'data' => $dbRowSet,
        'table' => 'log_email',
        'rowClass' => 'Models_DbTable_LogEmailRow'
));


Now I have the rowset I want and any row I pull out will have the data in
the relevant column processed.  Now this feels like a bit of a hack but
works perfectly for my needs.  Im open to suggestions as to how I can do
this another way


Happy Friday to you all who are still in Friday

- Chris

-- 
View this message in context: 
http://www.nabble.com/Using-Zend_Db_Table_Rowset-on-a-returned-set-tp20619749p20619749.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to