doubi1713
2014-07-24 08:19 阅读 59
已采纳

我将如何在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 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]
    
    点赞 评论 复制链接分享

相关推荐