当使用 cakephp Model->find() 方法时,我想以不同的方式对结果进行分组。
我的架构是:
`id` int(11) NOT NULL AUTO_INCREMENT,
`deviceid` varchar(255) NOT NULL,
`user_id` int(11) NOT NULL,
`sessionid` varchar(255) NOT NULL,
`ip` text NOT NULL,
`image_type` varchar(100) NOT NULL DEFAULT 'invalid_image',
`filename` text NOT NULL,
`analysis_basic` text COMMENT 'output from the image script',
`analysis_admin` text,
`created` datetime DEFAULT NULL,
`modified` datetime DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `sessionid` (`sessionid`)
在 cakephp 我想得到这样的东西:
Array
(
[0] => Array
(
[Picture] => Array
(
[sessionid] => somevalue
)
[0] => Array
(
[id] => 32
[deviceid] => 5124125
[userid] => 4541221
...and all other fileds
)
[1] => Array
(
[id] => 35
[deviceid] => 5124125
[userid] => 4541221
...and all other fileds
)
)
[1] => Array
(
[Picture] => Array
(
[sessionid] => someothervalue
)
[0] => Array
(
[id] => 38
[deviceid] => 5124454
[userid] => 34241
...and all other fileds
)
[1] => Array
(
[id] => 35
[deviceid] => 5124454
[userid] => 34241
...and all other fileds
)
cakephp 有可能吗?或者有没有更好的方法来实现类似于上面的东西?如果我能获得这样的结果,我知道 [0] 元素中的所有记录都具有相同的 sessionid .. 这就是原因。