我在让Zend_Db_Select从连接表中给出列值时遇到问题。例如,此连接有效:
$select->from(array('a' => 'files'), array('fil_last_name','fil_first_name','fil_middle_name'))
->join(array('b' => 'origination_offices'), 'a.fil_oof_id_fk = b.oof_id_pk', array());
但这不起作用:
$select->from(array('a' => 'files'), array('fil_last_name','fil_first_name','fil_middle_name'))
->join(array('b' => 'origination_offices'), 'a.fil_oof_id_fk = b.oof_id_pk', array('oof_name'));
也不是这样:
$select->from(array('a' => 'files'), array('fil_last_name','fil_first_name','fil_middle_name'))
->join(array('b' => 'origination_offices'), 'a.fil_oof_id_fk = b.oof_id_pk');
DbTable类看起来像这样:
class Application_Model_DbTable_Files extends Zend_Db_Table_Abstract {
protected $_name = 'files';
protected $_primary = 'fil_id_pk';
protected $_dependentTables = array(
'Application_Model_DbTable_NnFilesTags'
);
protected $_referenceMap = array(
'refProjects' => array(
'columns' => array('fil_pro_id_fk'),
'refTableClass' => 'Application_Model_DbTable_Projects',
'refColumns' => array('pro_id_pk')
),
'refOriginationOffices' => array(
'columns' => array('fil_oof_id_fk'),
'refTableClass' => 'Application_Model_DbTable_OriginationOffices',
'refColumns' => array('oof_id_pk')
),
'refResponses' => array(
'columns' => array('fil_res_id_fk'),
'refTableClass' => 'Application_Model_DbTable_Responses',
'refColumns' => array('res_id_pk')
),
'refZipCodes' => array(
'columns' => array('fil_zip_code_fk'),
'refTableClass' => 'Application_Model_DbTable_ZipCodes',
'refColumns' => array('zip_code_pk')
),
'refBoxes' => array(
'columns' => array('fil_box_id_fk'),
'refTableClass' => 'Application_Model_DbTable_Boxes',
'refColumns' => array('box_id_pk')
)
);
}
class Application_Model_DbTable_OriginationOffices extends Zend_Db_Table_Abstract {
protected $_name = 'origination_offices';
protected $_primary = 'oof_id_pk';
protected $_dependentTables = array(
'Application_Model_DbTable_Files'
);
}
为了获得联接表中的值,我需要做什么?