cakephp:结构数据库数据返回

时间:2014-05-14 08:03:30

标签: php mysql cakephp

可能返回的数据库查询如下所示:

array(
    (int) 0 => array(
        'Question' => array(
            'id' => '737',
            'question' => 'what is 1x7?',
        ),
        'Answer' => array(
            (int) 0 => array(
                'id' => '2373',
                'question_id' => '737',
                'correct' => true,
                'answer' => 'possible answer1',
                'created' => '2014-05-08 13:46:43',
                'modified' => '2014-05-08 13:46:43'
            ),
            (int) 1 => array(
                'id' => '2374',
                'question_id' => '737',
                'correct' => false,
                'answer' => 'possible answer2',
                'created' => '2014-05-08 13:46:43',
                'modified' => '2014-05-08 13:46:43'
            )
        ),
        'Linkquestioncategory' => array(
            (int) 0 => array(
                'id' => '608',
                'question_id' => '737',
                'category_id' => '5',
                'created' => '2014-05-08 13:46:47',
                'modified' => '2014-05-08 13:46:47',
                'Category' => array(
                    'id' => '5',
                    'name' => 'Simple Math',
                    'active' => true,
                    'linkquestioncategory_count' => '64',
                    'created' => '2014-02-03 09:20:54',
                    'modified' => '2014-03-04 14:47:05'
                )
            )
        )
    ),

为了清理它以避免发送许多不需要的数据=>我的问题是=>我怎样才能摆脱像

这样的领域
  • Answer.created
  • Linkquestioncategory.created
  • Linkquestioncategory.Category.created

我知道我可以使用条件'字段'来选择所选字段,但据我所知,这仅适用于'问题',但我如何操纵那些更深的数组数据? 我也可以使用'fields'条件吗?如果是,怎么样?

谢谢!

1 个答案:

答案 0 :(得分:0)