0

我目前正在尝试从 ipb 获取关系字段,但不知道如何。我目前正在使用页面应用程序并且有一个使用数据库关系的字段。这是获取关系字段的当前函数:

public function getReciprocalItems()
{
    /* Check to see if any fields are linking to this database in this easy to use method wot I writted myself */
    if ( \IPS\cms\Databases::hasReciprocalLinking( static::database()->_id ) )
    {
        $return = array();
        /* Oh that's just lovely then. Lets be a good fellow and fetch the items then! */
        foreach( \IPS\Db::i()->select( '*', 'cms_database_fields_reciprocal_map', array( 'map_foreign_database_id=? and map_foreign_item_id=?', static::database()->_id, $this->primary_id_field ) ) as $record )
        {
            try
            {
                $recordClass = 'IPS\cms\Records' . $record['map_origin_database_id'];
                $return[ $record['map_field_id'] ][] = $recordClass::load( $record['map_origin_item_id'] );
            }
            catch ( \Exception $ex ) { }
        }

        /* Has something gone all kinds of wonky? */
        if ( ! count( $return ) )
        {
            return FALSE;
        }

        return $return;
    }

    return FALSE;
}

ipb 用于显示的代码有点像树枝

4

0 回答 0