蛋糕查询:
$this->Token->find("first", array(
"conditions" => array(
"Token.token" => $token),
"contain" => array(
"TokenGroup" => array(
"TokenPermission" => array("fields" => array("path") )
) ) ));
返回(部分)如下内容:
[TokenGroup] => Array
(
[id] => 1
[name] => admin
[modified] => 2013-03-07 00:00:00
[created] => 2013-03-07 00:00:00
[TokenPermission] => Array
(
)
)
TokenPermition 数组是空的,但是当我使用 SQL 时:
SELECT
TokenPermission.path
FROM
tokens AS Token
INNER JOIN
token_groups AS TokenGroup ON (Token.token_group_id = TokenGroup.id)
INNER JOIN
token_groups_token_permissions AS JoinTable ON (TokenGroup.id = JoinTable.token_group_id)
INNER JOIN
token_permissions AS TokenPermission ON (TokenPermission.id = JoinTable.token_permission_id);
WHERE
Token.token = $token
它返回我 TokenPermission 数据:
[TokenPermission] => Array
(
[path] => TOKEN_NUMBER
)
此外,当我要求不同的用户组权限时,它可以返回分配给组号 1 的权限 - 这不是用户,而是管理员!
那么,如果 SQL 返回一切正常,为什么 Cake 看不到正确的关系呢?