gpt4 book ai didi

php - 使用链接表值扩展模型。在cakephp3中

转载 作者:行者123 更新时间:2023-11-29 22:35:09 25 4
gpt4 key购买 nike

开始学习cakephp3。有两个表

Task
-id
-task_type

Task_content
-id
-task_id
-some_key
-sove_val

在结果中我想得到一些对象,它看起来像:

{
id: Task.id,
type: Task.type,
title: Task_content.some_val (where some_key == 'title')
content: Task_content.some_val (where some_key == 'conent')
}

获取此对象的最佳方法是什么,只需通过“get”获取任务?

最佳答案

您需要制定一种行为来处理这个问题。您可以从 TranslateBehavior 中获得灵感,它的作用非常相似:

https://github.com/cakephp/cakephp/blob/master/src/ORM/Behavior/TranslateBehavior.php

关于php - 使用链接表值扩展模型。在cakephp3中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29572588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com