蛋糕查询:
$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看不到正确的关系?
答案 0 :(得分:0)
如果查看Cake运行的查询,您可以找到答案。将代码放在find方法之后:
$this->Token->->getDataSource()->getLog(false, false);