如何从CakePHP 3中的查询对象获取params

时间:2018-02-03 21:04:06

标签: php object cakephp cakephp-3.x cakephp-3.4

如何从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());

但没有工作。

3 个答案:

答案 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']);