利用relationModel关联查询,关联表字段重命名的问题

浏览:2212 发布日期:2013/09/24 分类:求助交流
我在使用relationModel使用关联查询的时候,需要把关联表的字段进行重命名,但是用field和定义关联表的对象重命名,都不行,大家有什么办法么?
下面是我的代码

SzCharacterModelclass SzCharacterModel extends RelationModel
{

    public $_link = array(
        'SzPhrase' => array(
            'mapping_type' => MANY_TO_MANY,
            'class_name' => 'SzPhrase',
            'mapping_name' => 'Phrases',
            'foreign_key' => 'cid',
            'relation_foreign_key' => 'phraseId',
            'relation_table' => 'sz_character_phrase'
        )
    );

}
关联表的模型class SzPhraseModel extends RelationModel
{

    protected $_map = array(
        'id' => 'Id', 
        'text' => 'Text',
    );

}
查询代码 $characterModel = D( "SzCharacter" );
        $todayMap[ "id" ] = array( 'in', $taskData[ "TodayTask" ] );
        $todayTask = $characterModel->field( $GLOBALS[ 'fieldConfig' ][ 'sz_character' ] )->relation(true)->where( $todayMap )->select();
        $taskData[ "TodayTask" ] = $todayTask;
最佳答案
评论( 相关
后面还有条评论,点击查看>>