如何从CakePHP 3中的查询对象中获取'params'?
$response = $this->getTable()->find();
// there are beforeFinds...etc that make this more complex
当我调试$response
时,我得到了这个(:
// ...
'(help)' => 'This is a Query object, to get the results execute or iterate it.',
'sql' => 'SELECT .... WHERE ... article_id = :c2',
'params' => [
':c0' => [
[maximum depth reached]
],
':c1' => [
[maximum depth reached]
],
':c2' => [
[maximum depth reached]
]
],
// ...
我想知道:c2
的价值是什么,但我似乎无法调试params
。
我试过这些:
\Cake\Error\Debugger::log($response->params);
\Cake\Error\Debugger::log($response->params());
\Cake\Error\Debugger::log($response['params']);
\Cake\Error\Debugger::log($response->getParams());
\Cake\Error\Debugger::log($response->getQueryParams());
但没有工作。
答案 0 :(得分:0)
通过增加调试的深度,我能够看到有条件的信息,包括:c2
的值
\Cake\Error\Debugger::log($response, 'debug', 4); // default depth is 3
答案 1 :(得分:0)
您应该可以通过$response->valueBinder()->bindings()
获取它们。
答案 2 :(得分:0)
您可以使用__debugInfo()
方法:
$result = $this->Pages->find()->where(['is_public' => 1]);
dd($result->__debugInfo()['params']);