How can I get Zend Db to return a set of strings rather than an array when executing a UNION query?

I have a result set that is the result of a MySQL UNION query. The code I use to retrieve the data is as follows:

$union_select = $PagesTable->getAdapter()->select()
        ->union(array('(' . $legal_resources_select . ')', '(' . $pages_select . ')'));
$PagesTable->getAdapter()->fetchAll($union_select)

$PagesTablegoes on Zend_Db_Table_Abstract. The full selection is too large for publication here, and I do not think that it is relevant to this particular issue. If I am wrong, let me know.

This currently returns an array of results, but I want it to return a rowset object. I must also indicate $_rowClass. This is necessary, so I can add methods to format and handle the return values.

Is it possible?

+3
source share
3 answers

. , , , , , .

Zend_Db_Table - Gateway Table Data , Active Record.

, , , Active Record, Doctrine 1.2, Zend_Db_Table.

+5

, rowClass rowsetClass, Zend_Db_Table,

Zend_Db_Table setRowsetClass setRowClass:

class RowTable extends Zend_Db_Table_Abstract {
    private static $_instance;
    protected $_name = "tableName";
    protected $_primary = "primary_key_id";

    # over-write the default class Zend_Db_Table_Rowset_Abstract
    # make sure the following classes are inside the include-path
    private function __construct($rowClass, $rowsetClass) {
        $this->setRowsetClass("ContributionList");
        $this->setRowClass("Contribution");
    }
}

$tableObject = new RowTable("RowClass", "RowsetClass");
+1

, , , , , , Zend_Db_Adapter , , Zend_Db_Table::getAdapter, , , , Zend_Db_Table::_fetch, Data Gateway.

, , , , , .

, , , , getAdapter. , , getAdapter select, , Zend_Db_Select, Zend_Db_Table_Select, Zend_Db_Table::_fetch, fetchAll fetchRow.

.

0

All Articles