关联数据的输出可以使用hidden(隐藏)、visible(显示)append(追加)方法进行控制。

    数据库表:Users表、Profile表

    Users表
    image.png
    Profile表
    image.png
    Blog表
    image.png
    1、hidden(隐藏)的用法

    Profile模型
    image.png

    Users模型
    image.png

    Users控制器
    image.png

    输出结果:
    image.png

    2、append(追加)的用法

    Blog模型
    image.png

    Profile模型
    image.png

    Users模型
    image.png

    User控制器
    image.png

    输出结果:

    append第一种用法的输出结果
    image.png
    append第二种用法的输出结果
    image.png