incidents
、およびの 3 つのテーブルがincident_properties
ありproperty_types
ます。
私がやりたいことは次のとおりです。
incidents
1 行のテーブルをクエリする- すべてのプロパティを取得します (キーと値の行と type_id です)。
property_type
プロパティごとに、テーブルからそのタイプを取得します
だから私はこのテーブル関係を設定しました -
class Incidents extends Zend_Db_Table_Abstract
{
protected $_name = 'incidents';
protected $_dependentTables = 'Properties';
}
class IncidentProperties extends Zend_Db_Table_Abstract
{
protected $_name = 'incident_properties';
protected $_dependentTables = 'PropertyTypes';
protected $_referenceMap = array(
'Incidents' => array(
'refTableClass' => 'Incidents',
'refColumns' => 'incident_id'
)
);
}
class PropertyTypes extends Zend_Db_Table_Abstract
{
protected $_name = 'incident_property_types';
protected $_referenceMap = array(
'Properties' => array(
'refTableClass' => 'IncidentProperties',
'refColumns' => 'property_type_id'
)
);
}
私のincidents
モデルマッパーでは、次のようなことをしたいと思います:
$select = $this->_dbTable->select()->where('id = ?',$incident->get_id());
$incident_properties = $this->_dbTable
->fetchRow($select)
->findDependentRows('IncidentsProperties')
->toArray();
print_r($incident_properties);
そして$incident_properties
、そのタイプ行内のプロパティのキー、値、およびタイプを取得します。
これを正しい方法で達成する方法はありますか?