dqd22496 2015-01-31 18:34
浏览 35

Cakephp从数据库中检索数据

I'm having trouble modeling my database. Currently it looks like this (I'm hiding the irrelevant fields): http://i.imgur.com/SF9FzaD.png

It is working fine, for example, when I want it to return a list of all the servers:

$this->Server->find('all');

It returns an array with the right information:

Array
(
    [0] => Array
        (
            [Server] => Array (...)
            [User] => Array (...)
            [Highlight] => Array
                (
                    [0] => Array
                        (
                            [id] => 39
                            [id_server] => 8
                            [id_highlight] => 1
                        )

                    [1] => Array
                        (
                            [id] => 40
                            [id_server] => 8
                            [id_highlight] => 5
                        )

                )
            [SubServer] => Array(...)

        )


    [1] => Array
        (
            [Server] => Array (...)
            [User] => Array (...)
            [Highlight] => Array
                (
                    [0] => Array
                        (
                            [id] => 41
                            [id_server] => 10
                            [id_highlight] => 4
                        )

                    [1] => Array
                        (
                            [id] => 42
                            [id_server] => 10
                            [id_highlight] => 5
                        )

                )
            [SubServer] => Array(...)

        )
)

In short, each game "server" has some kind of higlights pointed by the user. Like "Anti-cheat system", "Active staff", "Custom events", etc. Each of these highlights have an id and a name.

Is there a way to grab the name from the table highlight_names corresponding to each of the highlights.id_hightlight (and the rest of the data, like the array above) using Model::find()?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
    • ¥15 gdf格式的脑电数据如何处理matlab
    • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
    • ¥100 监控抖音用户作品更新可以微信公众号提醒
    • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
    • ¥70 2048小游戏毕设项目
    • ¥20 mysql架构,按照姓名分表
    • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
    • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
    • ¥15 linux驱动,linux应用,多线程