doubi1713 2014-07-24 08:19
浏览 78
已采纳

我将如何在generator.yml文件中创建JOIN?

I have a generator.yml file in the backend folder, the config in the generator file is:

generator:

config:
  actions: ~
  list:
    title: Send Email
    display: [subject, Body, email_Type_id, user_id]

  filter:
    display: [id, subject, Body, email, user_id]

The email_id and user_id was foreign key in the message table and primary key in (email table, user table), and it show in the fields the id but i want to let it show the user of the id that related to the message so i need to JOIN! how i will make it?

subject->Hello, Body->Hi iam.., Email_Type_id->1, User_id->8

In the email_id and user_id i want to show the user_name with the id 5 and in the email_type_id I want to show the type with id 1

  • 写回答

1条回答 默认 最新

  • doubi1818 2014-07-24 18:56
    关注

    The only way to do it is add the join in your model in a new getter and reference the getter in your generator config.

    public function getUser_name()
    {
        return $this->User->getName();
    }
    
    public function getEmail_type_name()
    {
        return $this->Email_type->getName();
    }
    

    Then in your generator:

    display: [subject, body, email_type_name, user_name]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿